views:

453

answers:

4

What are the suggested methods for using javascript files with MOSS 2007 ? in the 12 Hive somewhere or directly in the site's virtual directory in a scripts directory ? Or possibly as a embedded resource in a webpart ?

A: 

Mine where added to Sharepoint Designer in a folder I called "scripts" I think that puts it in the database.

MrChrister
+1  A: 

I suggest you deploy these scripts in the 12-hive.

  • Having them in the 12-hive ensures fast access, which is important for scripts. You risk page rendering lag otherwise. More admin overhead as you must deploy them on all frontend webservers in your farm.
  • Having them in the content DB makes them more centrally manageble at the const of performance.
driAn
A: 

We use a seperate scripts directory. We use a similiar approach to images.

This allows us to share images and Javascript easily between our webparts, and custom applications which are available though Sharepoint.

This should also mean they're only downloaded once, and cached.

Bravax
+1  A: 

Personally it all depend what purpose the javascript files are going to serve. If they're going to be shared amongst multiple components then I would suggest placing them in the 12-hive. If however, they're going to be isolated to a single component - a web part for instance - then embedding them as a resource will work as well.

This article has a discussion about best practices for the deployment of web part resources which you may find useful, in concludes:

In this post, you have seen how to both link to and embed Web Part resources. Each has its own advantages and disadvantages, mostly boiling down to whether you need to maintain the resource separately from the Web Part. In both cases, the resource file can be cached, so there is little performance difference from each option. Feel free to use one of these two approaches for your next web part.

Richard C. McGuire
Great response and link, thank you
Mcbeev