• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: css minified?
PostPosted: Wed Sep 05, 2018 1:01 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 83
Hi all, does anyone knows how to minify the default {cms_stylesheet} ?
is it possible to minify the css files?
thanks


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Wed Sep 05, 2018 2:28 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 469
Location: Victoria, BC
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.

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Wed Sep 05, 2018 3:13 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 83
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Wed Sep 05, 2018 7:06 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 83
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:
Code:
{capture assign=stylesheets}{cms_stylesheet nolinks=true}{/capture}
{cssMinifier css=$stylesheets}


next version will take the data from the database.
Let me know your thoughts.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Thu Sep 06, 2018 2:36 pm 
Offline
Power Poster
Power Poster

Joined: Sun Apr 19, 2009 9:33 am
Posts: 1267
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Thu Sep 06, 2018 3:47 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Feb 06, 2009 2:08 pm
Posts: 148
magallo wrote:
http://dev.cmsmadesimple.org/projects/cssminifier
Thank you!

magallo wrote:
Code:
{capture assign=stylesheets}{cms_stylesheet nolinks=true}{/capture}
{cssMinifier css=$stylesheets}

I was lazy and went with
Code:
{cssMinifier css={cms_stylesheet nolinks=true}}

... and it seems to work well. :)

(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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Thu Sep 06, 2018 5:40 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Mar 24, 2011 12:37 am
Posts: 83
PinkElephant wrote:
(It looks like the hardcoded 'tmp/cache' will miss when $config['tmp_cache_location'] is set).

You're making a good point, i was not aware of this $config option.

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']].....


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Fri Sep 07, 2018 6:32 am 
Offline
Power Poster
Power Poster

Joined: Sun Apr 19, 2009 9:33 am
Posts: 1267
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 --:

Code:
$uncompressed = $smarty->fetch('uncompressed.css');
minifyCSS($smarty->display('eval:'.$uncompressed));


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Sat Sep 08, 2018 2:27 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3020
Location: The Netherlands
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Thu Sep 13, 2018 1:39 pm 
Offline
Power Poster
Power Poster

Joined: Sun Apr 19, 2009 9:33 am
Posts: 1267
velden wrote:
Without having a look at the code I think it's bad practice to read the data from the database directly.


What do you mean?

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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: css minified?
PostPosted: Thu Sep 13, 2018 1:49 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3020
Location: The Netherlands
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']].....


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting