Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: maple on May 29, 2013, 12:11:24

Title: some css and js parts not minify
Post by: maple on May 29, 2013, 12:11:24
Hi,

I can see that unify all javascripts files into one file, but this file are not all compressed inside, only about a half.

Also, I can see that the file template.css don't unify with the other css's files.

My config: Gzip to "yes". Javascript and CSS minifier to "Yes+Gzip".


thanks
Title: Re: some css and js parts not minify
Post by: datahell on May 29, 2013, 12:30:17
The minified file is served compressed if you enable the gzip compression on the minifier.

The minifier handles files that have been added to elxisDocument library with $eDoc->adddStyleLink(...);
The template's css files are usually echoed in the end of the head section without using eDoc (in order to be sure there will be executed last). Such files cannot be handled by the minifier.
Title: Re: some css and js parts not minify
Post by: maple on May 29, 2013, 12:36:43
The minified file is served compressed if you enable the gzip compression on the minifier.

The minifier handles files that have been added to elxisDocument library with $eDoc->adddStyleLink(...);
The template's css files are usually echoed in the end of the head section without using eDoc (in order to be sure there will be executed last). Such files cannot be handled by the minifier.


I just attached the minified js file. If you scroll down, you can see that are not all compressed inside.  I have enabled the gzip.

Another issue, is possible to put the template.css file in eDoc mode to the last position? Can Works? Or could be gzip compressed at least, with a second css minified file or simply a template.css gzip compressed?
Title: Re: some css and js parts not minify
Post by: datahell on May 29, 2013, 19:56:42
gzip does not compress the file but serves it compressed.

Sample CSS files without the minifier = 35KB
Sample minified CSS size = 29KB (unified files, small size decrease)
Sample minified CSS served gzip compressed = 6KB (unified files, huge size decrease)

I attach a screenshot showing the HTTP headers of a gzip compressed minified CSS file.

Elxis minifier does not fully manipulate js/css files, it unifies them, removes empty lines and removes comments of this style /* comment */.
Title: Re: some css and js parts not minify
Post by: maple on May 29, 2013, 20:53:15
Well,

You say that remove empty lines. Why the js file that I attached before has not removed empty lines? (scroll down the file to see it)

It is possible to remove empty lines and comments in template.css file but without unifying with the others?

Also, it seems that gzip don't Works as well as yours. You go from 29kb unified css file to 6kb with unified files + gzip.
My css unified file, and the unified+gzip display the same size 27kb both. Something goes wrong.


My configs:

I have the gzip enabled and css to "yes+gzip compressed" into elxis performance Settings.

PHP server configs:

HTTP Headers:
Accept-Encoding -->  gzip,deflate,sdch

Phar:
gzip compression --> enabled


Apache Enviroment:
HTTP_ACCEPT_ENCODING --> gzip,deflate,sdch

Title: Re: some css and js parts not minify
Post by: datahell on May 29, 2013, 21:53:36
You don't understand. GZIP DOES NOT COMPRESS THE FILE, IT SERVES IT COMPRESSED! *
If you see the saved minified file saved in cache it will always be the same. But when Elxis serves it to the browser is compresses it on the fly!

Do this:
1. Set minifier to YES without gzip (MINICSS = 1 or MINIJS = 1).
2. Go to Elxis page do right click and get the full URL of the miinified file from the page's head section. For example:
Code: [Select]
http://www.example.com/inner.php/minify/9217cd1fbe722061d8c7e6ed9a6ece8d.css3. Copy-paste that URL in your browser and visit that page.
4. From firefox menu select Tools > Site information and check the size of the page. (A)
5. Set minifier to YES with gzip (MINICSS = 2 or MINIJS = 2).
6. Refresh the same page.
7. From firefox menu select Tools > Site information and check the size of the page. (B)

Compare sizes A and B.

* A simplified explanation on how gzip works
Let's say you request file test.txt which is 100 kb in size. With gzip (or apache's mod_deflate) apache compresses this file and instead of giving you test.txt is gives you text.gz which is much smaller (eg 15KB). Your browser decompresses it and show you the flat file as you had requested the non gziped file. The gziped file is actually a binary file. If you get it with CURL and echo its contents you will not see css/js flat text but useless binary code. This is why the decompress process by the browser is required. With gzip you save bandwidth and the site loads faster as the site's size is much smaller. The negative is that your browser will take more cpu resources for decompressing the file.
Title: Re: some css and js parts not minify
Post by: maple on May 29, 2013, 23:52:32
Ooohh   :o  I understand now. Lack of gzip tech knowledgement.

Thanks a lot for your time and explanations.

What about the firts two questions?:
You say that remove empty lines. Why the js  file that I attached before has not removed all empty lines? (removed about a half of them. Scroll down the file to see it)

It is possible to remove empty lines and comments also in template.css file like the others, but without unifying with them?

Thanks a lot