Due to performance problems, we decided to reference javascript files at the end of the master page file.

However, if we reference javascript files at the end of master page using ScriptLink Tag, the javascript files are always bound at the start of the page.

Is it possible to bind the javascript files at the end of page using ScriptLink Tag?

  • 1
    Why you want use ScriptLink? Are you JS custom files? Commented Mar 27, 2014 at 13:53

1 Answer 1



1) you are working with custom js code

2) you are working with a custom page


1) don't use ScriptLink :

If you register a .js file by adding a ScriptLink control to an .aspx page, the control registers all .js dependencies. To import the various "SP" namespaces, such as those listed at ECMAScript Object Model Reference, you must register the control as an on-demand script by specifying OnDemand="true". When you register the script, use the SP.SOD.execute or SP.SOD.executeFunc method to execute the script.

because, how you wrote, that link your script at the head of the page

2) In SharePoint 2010/2013, the correct way to execute function after script is loaded is to use something like this:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

3) Also you can register your custom js:

    SP.SOD.executeOrDelayUntilScriptLoaded(myfunction, 'sp.js');
    function myfunction() {
      // my custom code
      SP.SOD.executeOrDelayUntilScriptLoaded(myfunction2, 'custom.js');


Also with SP.SOD.registerSod you can register your own file: http://msdn.microsoft.com/en-us/library/ff411760(v=office.14).aspx


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.