How to Compress Your CSS With {cms_stylesheet}

CMS Made Simple attaches stylesheets to a page template with the {cms_stylesheet} tag. Since CMSMS version 1.10, this tag will automatically concatenate all of the stylesheets for a given media type into one CSS file.

You may not be aware that since version 1.10, you can use SMARTY tags inside of CMS Made Simple stylesheets. With a couple of small tricks, you can use this to compress your stylesheets.

Using [[strip]] Tags

In CMS Made Simple stylesheets, we use [[double braces]] instead of {curly brackets} as the SMARTY delimiter. This saves using a ridiculous number of {literal} tags.

On the first line of your stylesheet, put this tag: [[strip]], and on the last line put [[/strip]].

If you look at the resulting output, you will see that it has removed any line breaks tabs and double spaces. This compresses your stylesheet significantly, but there is still room for improvement.

Convert CSS Comments to SMARTY

Comments in CSS are written for you, the page developer, right? We don’t print out php comments in our rendered page code, so why should we print CSS comments in the rendered code?

I like to do a search-and-replace of my css files to convert /* into [[* and */ into *]]. This converts all of your CSS comments into SMARTY comments. They will not appear in the output.

Format Your CSS to Take Advantage of STRIP

[[strip]] will remove line-breaks, tabs, and convert multiple spaces into single spaces. You can optimize your CSS to be compressed by [[strip]] if you make a point of using tabs and line-breaks instead of spaces.

While [[strip]] is not a true CSS compressor, you can use it to produce highly compressed CSS with very little additional effort.

Your stylesheets will now be much more compressed if you follow these simple tricks.

Looking for quality CMS Made Simple Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under CMS Made Simple | RSS 2.0

Author Spotlight

Ken Griffith

Ken Griffith lives in Nairobi, Kenya and is a web developer for Cottage Networks. He uses CMS Made Simple as his preferred content management system for most web projects.

Leave a Reply

Your email address will not be published. Required fields are marked *


7 − 6 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>