In certain circles best practices suggest registering JavaScript files (js) at the end of a document to allow the DOM to completely load before invoking the js. This makes total sense but the question I have is if you are working with an asp.net webform and due to the postbacks I need to register the js files with the scriptmanager
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/js/jquery-1.7.js" />
<asp:ScriptReference Path="~/js/jquery.simplemodal-1.4.2.js" />
</Scripts>
</asp:ScriptManager>
Since the script manager has to be at the top of the document before any ajax features can be invoked it seems as if I am stuck registering the .js files at the beginning of the document.
Is this correct and are there other alternatives to registering the files at the bottom of the page to help boost page performance (aside from minifying the scripts. The above example is just a sample and not production code). Moving the js files outside of the script manager results in the pages loosing reference to the js file after the initial postback.
Cheers
I am not hugely familiar with the script manager class and why one needs to use it, but there is a property on the script manager called loadscriptsbeforeui that is set to true by default. Also, as for best practices, these should probably pulled from a cdn where they are much more likely to be cached and are not as high of risk as custom js files when loading before the UI.
All of that said, I am not sure why you can’t just drop the script manager and load them yourself with markup at the bottom. As long as the ajax code is loaded / run afterwards.
Perhaps I am missing some of your constraints though?