Julian Jelfs’ Blog

Another reason why the ScriptManager sucks …

Posted in Uncategorized by julianjelfs on August 1, 2009

There is a property on the ScriptManager called LoadScriptsBeforeUI. I have seen this little known property touted as a way to accomplish deferred script loading using the ScriptManager. However, it is not. To make sure that the UI is not blocked by your scripts you can use the defer attribute on the script tag. This is a good idea because  it means that the visible UI appears quicker which improves perceived performance. Setting aside the plainly ridiculous fact that this setting applies to the script manager as a whole rather than to individual script references – setting LoadScriptsBeforeUI to false does not add the defer attribute to the scripts, it simply moves them after any UI mark-up. This is good but it is not equivalent to the defer attribute which will also allow scripts to be downloaded in parallel (while maintaining execution order) whereas just moving them will not. So there must be some way to add the defer attribute to a script source using the ScriptManager mustn’t there? Nope. Perhaps because the defer attribute is perceived to be an IE only hack, but it is actually part of the html 4 spec though mysteriously not implemented by the other main browsers, which makes a change. So annoying.