Thursday, October 11, 2012

Where to deploy frontend files? Style Library vs _Layouts folder

I'm not going to repeat the stuff you already familiar with. The goal of this post is to summarize some findings and make a personal conclusion based on experience without requirement to read a lot.

Where to deploy css and JavaScript files? Basically we have 2 options:

  • SharePoint layouts folder
  • "Style Library" document library

Style Library benefits:

  • Resources are limited to site collection
  • Smart caching (if it was deployed)
  • Ability to update it on couple of front-end servers (after that you can't deploy new version of file without resetting to site definition) through UI
  • Style Library in URL looks prettier than _LAYOTUS (at first look)

Style Library Problems:
  • Frontend guys are not really good in merging of .spdata files
  • Frontend guys are not really good in modifying path attributes in Elements.xml
  • Actually you need to be prepared to spend 10-50% of your time helping to Frontend guys
  • Deployments during development phase are painful
  • If file was updated manually on production you will forget to reset it
  • Lower performance
  • It's really annoying
  • Caching is not as smart as you might think. Especially with custom NLB.
Layouts folder benefits:
  • Easy to use, straightforward
  • No iisreset/application pool recycling required. You can modify files directly in 14 hive, then Ctrl+F5 and voila!
  • Deployment issues? Forget about them.
  • Merging issues? Forget it
  • Better performance
  • You can be sure that nobody modified your files manually. Sometimes it happens.

Layouts folder Problems:
  • Not scoped. You need just to organize your files
  • Caching. More on that later (few days hopefully)
  • Ugly URLs. More on that
  • Sandbox solutions. Probably it won't work there. But I haven't really worked with them because I don't see any value in Sandbox solutions at this point.
Conclusion: use Layouts folder for your frontend files and be happy with SharePoint. Don't make things more complicated than they are.

Interested links:
http://sharepoint.stackexchange.com/questions/2219/css-files-in-layouts-or-document-library?lq=1
http://www.sharepointnutsandbolts.com/2011/11/avoiding-bugs-from-cached-javascript.html
http://www.sharepointnutsandbolts.com/2009/05/optimization-blob-caching-and-http-304s.html

No comments:

Post a Comment