Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

javascript and css optimization
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

Hi davidn,

I am fairly sure that it has to do with the double compression. When you for example type this address http://cakecraft.net/purchase/lib/minify/m.php?f=/skin/frontend/default/cakecraft/css/boxes.css you should see proper css.

I would suggest trying to disable zlib altogether. Either in htacces in the webroot. Or maybe this needs to be done via a separate php.ini file. Best to ask your webhost how this needs to be done.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidn
Jr. Member
 
Total Posts:  24
Joined:  2008-08-14
 

The webhost simplehelix suggests putting an .htaccess in the public_html folder
with the directive in it. Just to make sure I have this right, this is what I have in the file.
Is that correct?

############################################
## Disable zlib

zlib.output_compression = off

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

.htacess
php_flag zlib.output_compression off

on my setup I have to add a php.ini to /lib/minify/ with this content
zlib.output_compression = Off

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidn
Jr. Member
 
Total Posts:  24
Joined:  2008-08-14
 

Nothings working, I just don’t get it.  I’ve tried the .htaccess in the public_html, a php.ini file in the lib/minify. I just don’t understand why its not working. I will ask my webhost one more time and see if they have any more ideas.  Any other suggestions let me know. Thanks for your help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

Sorry don’t have any more suggestions at this stage. Just make sure to always delete all caches - even the crooked output will get cached! So after each try delete /var/minifycache, your browser’s cache and then ctrl+F5.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidn
Jr. Member
 
Total Posts:  24
Joined:  2008-08-14
 

should I also delete the cache in var/cache ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

/var/cache shouldn’t be necessary

One more thing you could try is editing /lib/minify/lib/HTTP/Encoder.php

Change

public static $compressionLevel 6;

to

public static $compressionLevel 0;

I haven’t tried this myself and it could reduce the effectiveness, but at least it could confirm where the problem lies.

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidn
Jr. Member
 
Total Posts:  24
Joined:  2008-08-14
 

Nope, no change. I checked the box.css and its a mess.

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

Hey David,

I got it to work. The trick was to force minify to use the same compression mechanism - gzip in your case. I also noticed that installations in subfolders seem to work with the same htacess as with webroot installlations so have changed the instructions accordingly.

thanks

For others having the same problem try editing the following in /lib/minify/m.php

from this

$serveOptions = array(
         
'files' => $servefiles
        
,'maxAge' => 31536000 // now + 1 yr
    
);

to this

$serveOptions = array(
         
'files' => $servefiles
        
,'maxAge' => 31536000 // now + 1 yr
        
,'encodeMethod' =>'gzip'
    
);
 
Magento Community Magento Community
Magento Community
Magento Community
 
Aikanet
Member
 
Avatar
Total Posts:  40
Joined:  2009-03-16
Düsseldorf, Germany
 

Hallo zusammen!

Damit nicht jemand genauso lange nach dem gleichen Bug suchen muss.
Falls ein Browser unregelmäßig (besonders der Internet Explorer) Probleme beim dynamischen Laden der Magento-Javascript-Dateien (per /js/index.php) hat, empfehle ich, auf manuelles Laden in Magento umzuschalten.

Das geht hier: System > Konfiguration > Erweitert > Entwickleroptionen

Grüße,
Rafael Kutscha

 
Magento Community Magento Community
Magento Community
Magento Community
 
EricO
Member
 
Total Posts:  63
Joined:  2010-04-02
 

Fooman:

I’m experiencing similar problems with Fooman Speedster.  We set it up recently and have been seeing a “400 Bad Request” error for cookies.js, as well as JavaScript errors saying various things are not defined.  Adding this line:

'encodeMethod' =>'gzip'
to $serveOptions in m.php got rid of the “400 Bad Request” error for cookies.js, but we’re still seeing the other JavaScript errors that various things are not defined.  For example, on the cart page:
Translate is not defined
<script type="text/javascript">var Translator = new Translate([]);</script></head

decorateTable is not defined
<script type="text/javascript">decorateTable('shopping-cart-table')</script>
When I go to the 1-page checkout page, I see even more of those (Class is not defined, Event.observe is not a function, VarienForm is not defined, etc., etc.).

We have mod_deflate and zlib set up in our Apache configuration, but even after disabling those, I still see these JavaScript errors.  I’m not sure what to try next..

 
Magento Community Magento Community
Magento Community
Magento Community
 
FOOMAN
Guru
 
Avatar
Total Posts:  669
Joined:  2007-12-13
Auckland, New Zealand
 

EricO’s solution is posted here.

 
Magento Community Magento Community
Magento Community
Magento Community
 
blitux
Jr. Member
 
Total Posts:  8
Joined:  2009-12-15
 

Hi there,

I think there’s more to optimize than just minifying and gzipping css and js files.

There’s a nice work that can be done on the front end, maybe generating a completely clean and reworked base theme, with a basic layout and using techniques like Object Oriented CSS [1] and some others like the ones that are explained in this wonderful presentation made by Nicole Sullivan, called Top 5 mistakes of Massive CSS [2]. I recommend to all of you, Magento themers and developers to read some entries at her blog. You will find it interesting, and maybe you could save hundreds (if not thousands) lines of CSS code.

The other side of optimization is about javascript. The base files are just too big. You can do a nice job on frontend, but there are way too many script tags all around the html, on different pages. As you may know, this script tags makes the browser stops rendering the page affecting the “perceived” page load time.

There is a technique that can be used: defering javascript load. Interesting. I’ve made some tests and the speed is just awesome. But there’s a drawback: all the script tags with functions in it, are expected to work after the js files are loaded and executed. So this technique can’t be used unless you rewrite ALL the javascript parts. Clearly a huge work, and without conventions about this, it could be a nightmare.

There’s also an important decision about what javascript lib to use. There has been some posts on this thread about this issue. I think jQuery is the best option because is the most popular javascript lib and this could be great for extension developers. This is just my opinion.

There’s a lot of work to do. Magento is a great e-commerce platform, but it has some weaknesses. Performance is one of them. Remember that google is taking speed as a variable to rank sites. Fast sites are first on searches. This could be good for magento too.

Come on Core Team, you can do it better! You can hire some perf and optimization ninja to work it out if you don’t have a people with these skills on your team. Or learn how to do it. I would love to see this on the roadmap. Maybe for the v1.5.

Keep up the good work!

References:
[1] http://www.stubbornella.org/content/2009/02/28/object-oriented-css-grids-on-github/
[2] http://www.stubbornella.org/content/2010/07/01/top-5-mistakes-of-massive-css/

 
Magento Community Magento Community
Magento Community
Magento Community
 
brucecaine
Jr. Member
 
Total Posts:  15
Joined:  2010-10-08
 

Yep, although not too certainly about how much of a public presentation boost it would bring to magento but Jquery’s smooth language is a plain beauty..

 
Magento Community Magento Community
Magento Community
Magento Community
 
Extendware
Sr. Member
 
Avatar
Total Posts:  231
Joined:  2011-08-04
 

If you want an enterprise level minifying solution, then look at our Site Optimizer Magento Extension.

It does a lot more than just minify CSS / JSS. It will:

Minify JS
Minify CSS
Miniy HTML
Minify inline JS / CSS
Cache minified versions and serve them via apache (not via php which is slow)
Pre-compress JS / CSS (faster and better on apache)
Properly enable caching on CSS / Catalog Images
Intelligently combine files to optimize page loading

You should look at the demo and see if it will suit your needs.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top