Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Do you deploy the script files to "_layouts" or the content database?

If "_layouts," do you use a <ScriptLink> tag or a <script> tag?

share|improve this question
2  
There was a very similar discussion on SO: stackoverflow.com/questions/1605564/… –  Stuart Pegg May 11 '11 at 20:30
add comment

3 Answers

Place your script files under

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\CUSTOMAPPNAME\JS

And add the script tag

<script type="text/javascript" language="javascript" src="/_layouts/CUSTOMAPPNAME/JS/script.js"></script>

Please don't put the script files in the content database. In other other words don't upload it into a Document Library etc, saves round-trip to the database to get the script files every time the page is refreshed.

share|improve this answer
2  
Dude has a point with performance. However, if you're developing for the sandbox, the content DB is your only option. And if you're developing for Office365... well the hardware's not your problem in the slightest (though might be an idea to keep an eye on the performance quota). –  James Love May 11 '11 at 19:47
    
Good point James! Since the question was "_layouts" vs "content db" we should assume he has access to deploy to "_layouts" folder. What do you think? –  Karthik Murugesan May 11 '11 at 19:50
    
Yup absolutely - thought it might add a bit of value for anyone else coming across the question. –  James Love May 11 '11 at 19:53
add comment

This has been discussed before recently.

Assetlib has its advantages (it gets cached so i wouldnt worry alot about performance) with versioning and can be used for cloud and multitenancy (as it is not stored on the disk). LAYOUT doesnt suffer from incorrect max-age, so a single roundtrip is saved here.

As always with SharePoint, the answer is, that it depends...

Regarding scriptlink and cssregistration i must admit i usually have CSS and HTML gurus to do that stuff for me, but i am sure i read somewhere that script and link tags are discarded by SharePoints safe mode parser. Anyways we always use scriptlink and cssregistration, since it is what the product does itself.

share|improve this answer
add comment

if you are deploying your master to the file system - then feel free to deploy your scripts there as well (_layouts\yourapp is the answer). If you are deploying your master to the gallery, put your scripts/styles on the same level as well (assetlib is cool). as you can see, I just want to bring scope/visibility to play here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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