We then refer to them in our page layouts and master page via
<script src=”/Style Library/project/myscript.js” />
It works fine on dev.
This makes no assumption about the web application or site collections of the destination server. When the site was exported and imported into various different site collection configurations, things start to go silly with 404 script file not found.
Site collection: http://mysharepoint.com/sites/mysite/
But the reference is still looking for http://mysharepoint.com/Style Library/project/myscript.js
Oops – 404 error.
The solution comes in a two steps:
- Deploy to _layouts/ instead, so the script resource is at
- Use the SharePoint control ScriptLink
<SharePointWebControls:ScriptLink Name=”/project/myscript.js” Localizable=”false” runat=”Server” />
- The localizable = false is important – otherwise SharePoint will look for