ScriptLink vs Script tag, what’s the difference?
This article specifically refers to the ScriptLink available in MOSS 07, as 2010 has other features such as script on demand which I will talk about another time.
If you are registering a script in your SharePoint Master Page, you basically have two options available to you. You can load it in this nice and fancy SharePoint way or just use the good old
We’ll i guess it really could depend on when you are looking to load your js file. With ScriptLink you have the ability to specify when you want the script to load asynchronously or after the after the page is ready. The ScriptLink will always look in /_LAYOUTS/1033 for the scripts.
This line would load the page and then load the script file. If you set Defer=”false” then the instant the page loaded and hit that line the .js file would execute.
Using Defer=”False” is basically the same as loading the script with this method. But with this method below you can specify a location other that LAYOUTS/1033 if you wanted to
Another difference with using the SharePoint:ScriptLink is that when the file gets loaded it must exist, otherwise you will get a SharePoint Error screen. This could help you ensure that SharePoint is seeing your js file.
So overall I don’t believe that there is much benefit from using the SharePoint:ScriptLink in Moss 2007, I personally use the to load all my custom js files. The jury is still out for 2010. I have yet to spend enough time experimenting with the newly added properties.