21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 368 Views |
-
Minify CSS?

26 June 2012 at 6:02am
Does anyone know if SS ever incorporated an easy way to minify css? I know the combine js method automatically minifies the js, but I haven't been able to find a way to make SS minify css. It's not a big deal to minify on my own, just thought maybe I was missing yet another cool built in action.
Thanks!
HB
-
Re: Minify CSS?

26 June 2012 at 6:27am Last edited: 26 June 2012 7:30am
to minify the css, its almost exactly like minifying the js.
Throw your css files into the array, then have the following line:
Requirements::combine_files('combinedCSS.css', $cssArray);
I don't add my IE style sheets though, because I call them like this:
Requirements::insertHeadTags('<!--[if IE 6]><style type="text/css">@import url(' . $themeFolder . '/css/ie6.css);</style><![endif]-->');
Edit: Almost forgot... Silverstripe will only minify your js and css if you are in "Live" mode.
-
Re: Minify CSS?

26 June 2012 at 7:42am Last edited: 26 June 2012 7:53am
That's close to the same code I've been using. I had $CSSFiles instead of $cssArray. It definitely combines the files but doesn't seem to be stripping anything like comments or moving the code so that it is inline. The javascript looks like a min file - no white space, no comments, etc..., but the css just combines whichever files I am combining. Kind of quirky...perhaps it's because I am still using an older version of SS (2.4.5) I just tried the $cssArray but it seems to have made the page load slower so I went back to the original code.
I did know about the live mode, but thanks for the heads up. I'm sure someone reading this would probably be banging their head against the wall if they tried it in dev...
Thanks for your input!
| 368 Views | ||
|
Page:
1
|
Go to Top |


