Minifying CSS & HTML

Paul Truman asked on February 19, 2014 10:10

Hello there, I'm trying to use the compression options for minfying CSS & Javascript in Kentico. I have all the options tickets under Settings > Performance (and GZip static & dynamic enabled on my IIS 7) - but when I check my page speed results on PageSpeed (for example) it's telling me that my CSS and HTML isn't minified.

I would assume that the compression option is working as the Javascript is being flagged up as being compressed.

I have my stylesheets set up under Development > CSS StyleSheets and all of the CSS rules are within the 'General' Tab.

I have this stylesheet selected as the primary stylesheet for my site. Is there anything else that I'm missing?

Many thanks

Regards

Paul

Recent Answers


Martin Danko answered on February 19, 2014 20:38

Hello Paul,

You can simply check the source code of your page for the following:

CMSPages/GetResource.ashx?stylesheetname=stylesheet_file = CSS minification is working.

CMSPages/GetCSS.aspx?stylesheetname=stylesheet_file = no minification. 

You can also take a look at the response header with and without CSS minification enabled, and focus on the Content-Length, you will see they are different.

The CSS files are not minified physically but programatically on the request so not sure how exactly are you testing Page Speed but when the test is trying to get the physical CSS file, it will never receive the minified version because as I've mentioned before, Kentico is not touching the physical file.

Best regards, Martin

3 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 20, 2014 00:04

Anytime you use /CMSPages/GetResource.ashx AND you have minification enabled, your files will be minified. Be sure if you are manually including any script files to include them like so: <script src="/CMSPages/GetResource.ashx?scriptfile=/CMSScripts/jquery/jquery.slides.js"></script>

If using custom CSS, do as Martin suggests.

1 votesVote for this answer Mark as a Correct answer

Victor Hugo Garcia answered on March 6, 2014 09:01

I suggest you perform a minification with line break enabled by class and that way you will get around 25% of size of the file, and then Kentico will minify that some (ms) faster.

suggestion: GruntJs to minify.

0 votesVote for this answer Mark as a Correct answer

tony tong answered on December 10, 2015 03:00

You can simply check the source code of your page for the following:

CMSPages/GetResource.ashx?stylesheetname=stylesheet_file = CSS minification is working.

CMSPages/GetCSS.aspx?stylesheetname=stylesheet_file = no minification. You can also take a look at the response header with and without CSS minification enabled, and focus on the Content-Length, you will see they are different.

The CSS files are not minified physically but programatically on the request so not sure how exactly are you testing Page Speed but when the test is trying to get the physical CSS file, it will never receive the minified version because as I've mentioned before, Kentico is not touching the physical file.

very useful information.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.