views:

264

answers:

3

Besides the obvious benefit of placing the custom javascript files (or any other resource files) in a document library, such as:

  • versioning, history, tracking
  • easy to change/edit

Is there any other benefits?

Performance? Page Load time?

Are there any cons?

PS. This is not meant as a question on number of files / resources has a general HTTP performance, but rather this specific SharePoint issue on the file location.

http://site/_layouts/myjavascript.js

vs.

http://site/DocumentLibrary/myjavascript.js
A: 

have you considered using google to host javascript files (such as jquery)

  • this benefits from using their bandwidth for downloading the files
  • faster page loading times
  • higher availability
  • chances are high that your javascript file is already cached on the user's machine
Rob
Hi. Nope. Internal site. No guarantee that all clients has internet access.
Magnus Johansson
good point hadn't considered that.
Rob
+2  A: 

Tf you are storing the js in a library then it is stored in the database.

It means that:

  1. it has version control

  2. it is slower then the filesystem (unless you are using blob cache)

  3. it will be included in any backups you do of your sharepoint install (stsadm for example)

  4. it will be accessible (changeable) by anyone with access to the document library (easier to maintain, less secure)

  5. client side caching will behave differently (you'll need to configure it, it's a bit complicated for MOSS content vs filesystem content)

We decided to store it in the 12 hive as it feels better in regards to code vs. data separation. If you consider this file to be data then store it in MOSS, if you consider it to be "code" then store it in the filesystem.

Nir Levy
Good list. One extra consideration might be how you want to reference the resource files though. Relative links are easier if you know your stuff is in _layouts.
Sam Yates
A: 

Document Library

Pros - Automatic delivery to all web front ends, easy, versioning, history, ease of editing

Cons - Slower (it's in the database),Security issues brought about by accidentally securing the item's site, login prompts if you are referencing the js via absolute URL your users may get repeated login prompts

Plasing the js file in the 12 hive

Pros- faster, no issues with the aformentioned security prompts

Cons - Not automagically delivered to all of your web front ends, possible AAM issues, technically you are not supposed to modify files in the 12 hive

UJ
If you use a solution those files do indeed get "automagically" delivered to all your WFEs. Also, there's no restriction on putting files in the 12 hive. You're just not suppposed to modify the OOTB files.
Sam Yates
Since web requests to a doc lib most certainly will be cached when multiple users constantly access a js file, I wonder if it really will be slower that file cache? Also, I would say that you indeed must modify you files in the 12 hive for, how would you otherwise customize (advanced) SharePoint? The key here is not to modify the **OOB** Microsoft files.
Magnus Johansson