css minified?
css minified?
Hi all, does anyone knows how to minify the default {cms_stylesheet} ?
is it possible to minify the css files?
thanks
is it possible to minify the css files?
thanks
Re: css minified?
There's no plugin for that currently, but enough people have asked for it that I'm sure someone would write one if a few people could sponsor it.
You can always just use [[strip]] in your stylesheet templates and be most of the way there, and if you're using compression on your server, then minifying won't really accomplish anything anyway - other than silencing SEO experts.
You can always just use [[strip]] in your stylesheet templates and be most of the way there, and if you're using compression on your server, then minifying won't really accomplish anything anyway - other than silencing SEO experts.
Not getting the answer you need? CMSMS support options
Re: css minified?
Thanks for the feedback, in fact I do need to silence the seo experts
I'm going to give it a try. I'm also going to try using the [[jsmin]] tag. Lets see if it helps.
I'm going to give it a try. I'm also going to try using the [[jsmin]] tag. Lets see if it helps.
Re: css minified?
I created a plugin that would minify the existing default {cms_stylesheet} here:
http://dev.cmsmadesimple.org/projects/cssminifier
to use it, you need to add the following into the template:
next version will take the data from the database.
Let me know your thoughts.
http://dev.cmsmadesimple.org/projects/cssminifier
to use it, you need to add the following into the template:
Code: Select all
{capture assign=stylesheets}{cms_stylesheet nolinks=true}{/capture}
{cssMinifier css=$stylesheets}
Let me know your thoughts.
Re: css minified?
Ofcourse somebody will write a CSS optimization module when enhough funds are raised. But there are already tremendous JavaScript optimizers that are hard to beat and standardized on other open-source projects.
Implementing pre- and postprocessors is something you can start with today for example: Export your Design Manager CSS files and compress them with: cssnano + css-mqpacker
https://cssnano.co
https://github.com/hail2u/node-css-mqpacker
Btw: When you bump the exiration dates on the default cmsms/doc/htaccess.txt file (access plus 1 year) most speed test tools also give a better score. SEO fanatics will love it.
Implementing pre- and postprocessors is something you can start with today for example: Export your Design Manager CSS files and compress them with: cssnano + css-mqpacker
https://cssnano.co
https://github.com/hail2u/node-css-mqpacker
Btw: When you bump the exiration dates on the default cmsms/doc/htaccess.txt file (access plus 1 year) most speed test tools also give a better score. SEO fanatics will love it.
- PinkElephant
- Forum Members
- Posts: 169
- Joined: Fri Feb 06, 2009 2:08 pm
Re: css minified?
Thank you!magallo wrote:http://dev.cmsmadesimple.org/projects/cssminifier
I was lazy and went withmagallo wrote:Code: Select all
{capture assign=stylesheets}{cms_stylesheet nolinks=true}{/capture} {cssMinifier css=$stylesheets}
Code: Select all
{cssMinifier css={cms_stylesheet nolinks=true}}
(It looks like the hardcoded 'tmp/cache' will miss when $config['tmp_cache_location'] is set).
Why this matters to SEO is beyond me.
EDIT: Forgot to say it might be worth including additional css units like rem.
Re: css minified?
You're making a good point, i was not aware of this $config option.PinkElephant wrote:(It looks like the hardcoded 'tmp/cache' will miss when $config['tmp_cache_location'] is set).
btw, i already have a working version that grabs the data directly from the database but it will only convert [[root_url]] to $config['root_url']. I think it's too complicated to convert all the smarty processing : [[$red = '#900' scope='global']].....
Re: css minified?
Css Custom Properties catch up and will become a good replacement for variables set in Smarty in after ie11 is phased out: https://caniuse.com/#feat=css-variables.
Maybe you can process (the uncompressed) CSS templates through Smarty first and put that into your minifyCSS function after.
https://www.smarty.net/docsv2/en/api.functions.tpl
-- untested --:
Maybe you can process (the uncompressed) CSS templates through Smarty first and put that into your minifyCSS function after.
https://www.smarty.net/docsv2/en/api.functions.tpl
-- untested --:
Code: Select all
$uncompressed = $smarty->fetch('uncompressed.css');
minifyCSS($smarty->display('eval:'.$uncompressed));
Re: css minified?
Note:
Without having a look at the code I think it's bad practice to read the data from the database directly.
Available API's should be used.
Without having a look at the code I think it's bad practice to read the data from the database directly.
Available API's should be used.
Re: css minified?
What do you mean?velden wrote:Without having a look at the code I think it's bad practice to read the data from the database directly.
cssMinifier is reading a file from the tmp directory.
smarty methods are not protected and part of the cmsms api.
my example is pseudo code btw.
Re: css minified?
magallo wrote: ...
btw, i already have a working version that grabs the data directly from the database but it will only convert [[root_url]] to $config['root_url']. I think it's too complicated to convert all the smarty processing : [[$red = '#900' scope='global']].....