librelist archives

« back to archive

Minify of CSS & JS

Minify of CSS & JS

From:
William Martin
Date:
2011-07-24 @ 20:24
Hi,

If i find a couple of hours, the next week. I will create the
namespace "photon\minify" to handle the minification of CSS and JS in
simple function.
JS-Min have a PHP implementation so it's will be easy. For the CSS, i
found an class in ruby, most use opration is an gsub, like an
preg_replace in PHP.

Prototype of functions can be :
<str minified> = \photon\minify\css(<str large>)
<str minified> = \photon\minify\js(<str large>)

In a second time, we can use it to generate more small file in the PHAR.
I lets Loic find an pragmatic solution like the ".pharignore" to do that.

William

https://github.com/rgrove/jsmin-php/
https://github.com/rgrove/cssm


-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Minify of CSS & JS

From:
Thomas Keller
Date:
2011-07-24 @ 22:35
Am 24.07.11 22:24, schrieb William MARTIN:
> Hi,
> 
> If i find a couple of hours, the next week. I will create the
> namespace "photon\minify" to handle the minification of CSS and JS in
> simple function.
> JS-Min have a PHP implementation so it's will be easy. For the CSS, i
> found an class in ruby, most use opration is an gsub, like an
> preg_replace in PHP.
> 
> Prototype of functions can be :
> <str minified> = \photon\minify\css(<str large>)
> <str minified> = \photon\minify\js(<str large>)
> 
> In a second time, we can use it to generate more small file in the PHAR.
> I lets Loic find an pragmatic solution like the ".pharignore" to do that.

I've never understood the drive for "minification" actually. If its only
about the size, gzip compression does a better job anyways, so one
should look into that. And even if its about obfuscating the sources -
which is against my mantra to supply open code "for learning purposes",
but well - then a real obfuscator that would change variable names would
be more useful.

So the question is - what should be achieved?

Thomas.

-- 
GPG-Key 0x160D1092 | tommyd3mdi@jabber.ccc.de | http://thomaskeller.biz
Please note that according to the EU law on data retention, information
on every electronic information exchange might be retained for a period
of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en

Re: [photon.users] Minify of CSS & JS

From:
William Martin
Date:
2011-07-25 @ 07:50
Hi,

I don't want to do obfuscating, just minification. The goal is to
reduce the size of thoses files in a production context, and reduce
the network traffic.

An example on jquery-1.6.2.js :

Minified       Gz              Size
-----------------------------------------------------------
No              No              230Ko (100%)
Yes             No              89Ko  (38%)
No              Yes             66Ko (29%)
Yes             Yes            31Ko  (13%)

The best choice is to package the file minified and compressed.
Serve a minified file is the same action for photon as to serve not
modified file.
I don't know, if photon can send a compress answer. Loic can you tell
us about that ?

William

On Mon, Jul 25, 2011 at 12:35 AM, Thomas Keller <me@thomaskeller.biz> wrote:
> Am 24.07.11 22:24, schrieb William MARTIN:
>> Hi,
>>
>> If i find a couple of hours, the next week. I will create the
>> namespace "photon\minify" to handle the minification of CSS and JS in
>> simple function.
>> JS-Min have a PHP implementation so it's will be easy. For the CSS, i
>> found an class in ruby, most use opration is an gsub, like an
>> preg_replace in PHP.
>>
>> Prototype of functions can be :
>> <str minified> = \photon\minify\css(<str large>)
>> <str minified> = \photon\minify\js(<str large>)
>>
>> In a second time, we can use it to generate more small file in the PHAR.
>> I lets Loic find an pragmatic solution like the ".pharignore" to do that.
>
> I've never understood the drive for "minification" actually. If its only
> about the size, gzip compression does a better job anyways, so one
> should look into that. And even if its about obfuscating the sources -
> which is against my mantra to supply open code "for learning purposes",
> but well - then a real obfuscator that would change variable names would
> be more useful.
>
> So the question is - what should be achieved?
>
> Thomas.
>
> --
> GPG-Key 0x160D1092 | tommyd3mdi@jabber.ccc.de | http://thomaskeller.biz
> Please note that according to the EU law on data retention, information
> on every electronic information exchange might be retained for a period
> of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en
>
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] Minify of CSS & JS

From:
Thomas Keller
Date:
2011-07-25 @ 08:25
Am 25.07.2011 09:50, schrieb William MARTIN:
> Hi,
>
> I don't want to do obfuscating, just minification. The goal is to
> reduce the size of thoses files in a production context, and reduce
> the network traffic.
>
> An example on jquery-1.6.2.js :
>
> Minified       Gz              Size
> -----------------------------------------------------------
> No              No              230Ko (100%)
> Yes             No              89Ko  (38%)
> No              Yes             66Ko (29%)
> Yes             Yes            31Ko  (13%)

Ok, I didn't know that minification before compression does make such a 
huge difference. Thanks for sharing that and nevermind my other 
arguments then :)

Thomas.

-- 
GPG-Key 0x160D1092 | tommyd3mdi@jabber.ccc.de | http://thomaskeller.biz
Please note that according to the EU law on data retention, information
on every electronic information exchange might be retained for a period
of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en

Re: [photon.users] Minify of CSS & JS

From:
William Martin
Date:
2011-07-25 @ 09:16
The minification is just removing all esthetic characters :
- multiple space, line return
- indentation
- comments

If you use a tool like http://jsbeautifier.org/ to format again the
code. Try with the minified version of jquery
http://code.jquery.com/jquery-1.6.2.min.js

William

On Mon, Jul 25, 2011 at 10:25 AM, Thomas Keller <me@thomaskeller.biz> wrote:
> Am 25.07.2011 09:50, schrieb William MARTIN:
>> Hi,
>>
>> I don't want to do obfuscating, just minification. The goal is to
>> reduce the size of thoses files in a production context, and reduce
>> the network traffic.
>>
>> An example on jquery-1.6.2.js :
>>
>> Minified       Gz              Size
>> -----------------------------------------------------------
>> No              No              230Ko (100%)
>> Yes             No              89Ko  (38%)
>> No              Yes             66Ko (29%)
>> Yes             Yes            31Ko  (13%)
>
> Ok, I didn't know that minification before compression does make such a
> huge difference. Thanks for sharing that and nevermind my other
> arguments then :)
>
> Thomas.
>
> --
> GPG-Key 0x160D1092 | tommyd3mdi@jabber.ccc.de | http://thomaskeller.biz
> Please note that according to the EU law on data retention, information
> on every electronic information exchange might be retained for a period
> of six months or longer: http://www.vorratsdatenspeicherung.de/?lang=en
>
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com