One of the simplest ways to improve your website is by optimizing and minifying the stylesheets and scripts in your pages, and umbraco has a built-in compression tools named ClientDependency which you can use out of the box.
It’s easy to get ClientDependency working on your website since it is already set up in Umbraco, so there’s no need to change configuration files. Asumming that all you css and js are located in the /Css and /Scripts, create an user control and register the ClientDependencyLoader:
1 2 3 4 5 6 7 8
Then create a macro pointing to this user control and reference it in your masterpage. For more information about how to setup ClientDependency for webforms, visit the documentation in the codeplex project.
Follow these steps to finish configuration:
- Delete the generated file App Start Combres.cs
- Remove the reference to the assembly WebActivator
- Delete the App global.asax.dll from the bin folder
- Create your own global.asax file with the following code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Edit App Data/Combres.xml to include your JS and CSS resources
- Put these in your master page.
- Optional: Move the Combres.xml file to the Umbraco config file, rename it to Combres.config and update the webconfig to point to this file
Finally, have a look at the 5 minutes Quick Start in the codeplex documentation and at the combres.readme file downloaded from Nuget. Take into account that the Nuget package will also install and set up dotless. If you want to use it, see the .LESS and integration into Umbraco and Using .LESS and the Client Dependency Framework in Umbraco links.