Minification is a well-known method for optimizing performance of public-facing websites. Unfortunately, often the process is tedious and disregarded. What if you could have SharePoint automatically minify your assets for you?
Performance is the key
Event though the speed of Internet connections is continuously improving, the importance of performance increases. We become more impatient and we want to get to our information faster. Limiting the size of a website can help you have it load quicker.
Inconvenient assets minification
If you are a developer and you are building websites there is a chance that you have the process of minifying and combining assets configured as a part of your build process. With a single click of a button the assets are merged into one or more files and their contents are minified. As a result the customer gets optimized files which load faster than their raw versions.
What if, however, you are not a developer and are building websites through customizations? Is the tedious process of manual assets minification the only way or is there a better approach?
The first thing that you have to do to have your asset files minified is to create a folder using the Assets Folder Content Type. While creating an asset folder there are a few properties that you can specify:
- Name: this is the name of the folder
- Target File Name: the name of the file that will be generated by Mavention SharePoint Assets Minifier and will contain minified and merged contents of all asset files from that folder
Once created, the next step is to upload your asset files. After uploading a file you should change its Content Type to Asset File.
One property that you can additionally set in the Asset File Content Type is Sort Order and which specifies the order in which the contents of the asset files will be merged. This is important if there are dependencies between the particular files in the same asset folder.
Once you save the changes the minified asset file will be generated.
As you add more files all of them will be merged into the asset file which you can reference in your website.
The same process applies to minifying and merging Style Sheets. The only difference is that you have to set the Asset Type property on the asset folder to StyleSheet.
Download: Mavention SharePoint Assets Minifier (WSP, 178KB)