2

For SharePoint development, I am used to placing all the images/CSS/JS files into the mapped layouts folder (..\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS) using Visual Studio. Recently, I saw my colleague using the STYLES folder in the layouts to store the CSS files.

Are there any implications or differences in the way we are storing the files? Just curious on what could be the best practice to store these files.

In addition, the files are located under a folder that goes by the name of the Project (i.e. \Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\Project1.Branding). What if I need to reuse certain images/CSS/JS files for a different project, what will be the proper way of reusing these?

Edit: I do not understand why people are marking this as duplicate with the question comparing Document library with layouts. My question relies on layouts alone, the Style (found under layouts) folder is also a mapped folder in visual studio. Please enlighten me with this.

1

Considering you are not interested in the whole document library VS mapped folder discussion, I believe that the main reason for placing branding elements (aka CSS) in the "Styles" mapped folder, instead of the parent, "Layouts" is mainly when you want to use the Themable engine.

Whether you want to host your resources in a site or directly reference them from the hive, if I remember correctly, you must place them in Styles > Themable. Other then that, they are just a place in the file system where you decide to put CSS.

2

If you use file system then during system backup those files will not get backed up. This is the same case with system migration. All files in file system needs to be moved separately.

On the other hand if you use libraries then those files will be placed in the content database and will be included in backup as well as system upgrade etc.

If you place files in style library, make sure you are placing it in the root site collection and using proper token to access those files from sub sites. Another advantage is you can set permission on those files.

  • 1
    If you manually deploy files (which you should never do) they don't get backed up. If you deploy the files via a solution package (WSP) they do get backed up. The files are in the solution package and the solution package is in the configuration database. – Rob Windsor Jul 1 '15 at 14:11
0

To me, it depends on what you are doing. If you are deploying a branding feature, then I would deploy it to the file system. This way you don't have hundreds of copies of your CSS and JS files lingering around. One place, easier to update should changes be necessary.

If the feature is site or site collection scoped, than I tend to do the style library or an Assets library.

0

The answer, as always, is it depends.

The first thing to consider is scope. Where are these files going to be used? If they are going to be used farm-wide then it makes most sense to deploy them to the _layouts folder. If they need to be visible at the site collection level then style library or site assets makes sense.

You also need to consider whether users need to/should be able to edit these files using the browser. If the answer is no then you should consider using a virtual folder rather than a library like the style library or site assets.

You also need to take into account your environment and the options you have for deployment. What if you're targeting SharePoint Online? That eliminates the option of deploying to the _layouts folder. But what if you want the files to be visible tenant-wide? Well, you need to come up with a workaround. The general consensus now is to implement a local Content Delivery Network (CDN).

So, without even considering the possible edge cases, you can see that there is no simple answer to you question.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.