Is it wise to store images and css for the site in the layouts/1033 folder within a .wsp and then letting the deployment of the .wsp take care of location, i.e. dont use elements.xml etc.

I seem to remember there being a gotcha with this whereby they would not be accessible when the _layouts is locked down. It appears to work on the face of it though.

All the best


Ways to determine if you want to store images in _LAYOUTS and in shared image libraries like Style Library:

  • If you want your end users to edit/create new versions of your data you should choose Style Libraries (or Image Libraries) and if you dont want end users to mess around with layout images etc choose _LAYOUTS (in a subfolder!)
  • Performance wise, images/css/js stored in image libraries can be cached using External Storage Locations (BLOB storage). (In my experience, still after SP2 ESL is still quite buggy and you will need to flush the disk based cache regularily to avoid JS errors)
  • Host header on image libraries does not set max-age property correcly. This triggers alot of 304 traffic from the client to the server. You dont have this problem in _layout folder (read, http://www.kindohm.com/archive/2008/06/20/eliminating-quot304quot-status-codes-with-sharepoint-web-folder-resources.aspx )
  • If you want your binaries to vary based on regional settings, choose the appropriate subfolder in layouts (eg 1033)

Theres probably more, but thats just off the top of my head what i use myself to determine where i store my binaries

| improve this answer | |
  • +1 Regarding point 1 though, you never know when a site collection admin may have a need to edit these files in the future. Surely you can use permissions to effect this rather than removing them from the UI completely. Point 3 is interesting, def going to read that article. Thanks Anders. – Charles Lee Feb 26 '10 at 8:39
  • Ah, another reason to not use _layouts would be if you want to load the elements for use in a Content Query webpart. That webpart simply won't load anything from _layouts. However, if you have your own solution, I agree with Anders Rask in the matter. – bgmCoder Oct 11 '12 at 18:16

I often store images, css, js, etc somewhere in a sub folder under _layouts and deploy these files using WSP deployment. I haven't really experienced any issues with this approach.

I'd say it's safe.

| improve this answer | |

I think it depends on your situation. I have used this approach as well as embedding them as assembly resources for web parts, or using the _wpresources folder. In publishing sites I have deployed branding files into the style library.

There are many ways to approach this depending on the project you are working on. I tend to prefer to deploy artifacts into sharepoint libraries ghosted from the feature folder which deployed them (as it groups the files together), but that is just a personal preference.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy