简体   繁体   中英

Best practice - MOSS 07 and Javascript Files?

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 ?

Personally, it all depends on 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.

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.

我在我称为“脚本”的文件夹中添加到 Sharepoint Designer 的位置,我认为将其放入数据库中。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM