There is always the ASP.net way of registering JavaScript on the page using the Page.ClientScript.RegisterClientScript()
method, but I was wondering if there was a better way to register your JavaScript files for SharePoint. I see that SharePoint has a ScriptLink
control that can be used as well.
I was wondering this because it was my understanding the standard Page.ClientScript.RegisterClientScript
method will use the type and the name to create a registration key so that the JavaScript is only provided once on the page. I see that the ScriptLink
control does not take a type or a key, so I was wondering if it has similar properties and if it might be better to utilize the ScriptLink
control rather than the Page.ClientScript.RegisterClientScript
method.
As I am sure you can see, if you have multiple instances of jQuery loading for instance with plugins, the second load of your jQuery libraries will overwrite your initial instance and the plugins that were initially added will be unavailable. Coupling this with the fact that you may have competing vendors installing projects in the farm, they may be using some of the backing libraries and cause this to fail.
So what do you guys think?
Is there another method that I should be leveraging to register my JavaScript libraries?