Enable Composite Files and Minify CSS and JS in DNN
Posted in DNN on February 1, 2019
Here's how you can enable composite files and minify CSS and JS in DNN.
Pre-requisites
For your CSS and JS, you need to use the Client Dependancy Framework to load CSS and JS through your skin and modules. You can learn more about that here: https://www.dnnsoftware.com/wiki/client-resource-management-api
The basic gist of it is this:
- Include this in the head of your skin:
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>
- Load your CSS like this:
<dnn:DnnCssInclude runat="server" FilePath="DNNMega/dnnmega.css" PathNameAlias="SkinPath" />
- Load your JS like this:
<dnn:DnnJsInclude runat="server" FilePath="~/Resources/Shared/Scripts/jquery/jquery.hoverIntent.min.js" />
Once you have your resources loading properly in your DNN Theme / Skin, DNN knows how to properly compress and minify them. Now you simply follow these instructions to turn on composite files and minification:
- Log in with your SuperUser account
- In the control panel, hover over the Settings (gear) icon
- Click "Servers"
- Click the "Server Settings" tab
- Click the "Performance" sub-tab
- At the bottom there is "Client Resource Management"
- Choose either the "Global" radio button (if it's for all sites on the instance) or the radio button for your one specific site
- Toggle "Enable Composite Files" on
- Toggle "Minify CSS" on
- Toggle "Minify JS" on
- Click Save
- Once the page refreshes, click "Increment Version"
- Test, test, and test again*
* Sometimes things can go wrong with composite and minified files. Dependencies get out of order, maybe a third party module breaks. It's super important to review all the pages and the functionality of your website.
That's pretty much it! I hope this helps you fine-tune the performance of your DNN website. If you're looking for extra help with making fast-loading, hyper-usable DNN websites, please check out Expert DNN Development. I can help you make your DNN website load faster and a dream to use for you and your customers.
Aaron Lopez
Founder & Lead Developer at Wolf X Machina