EasySocial 2.2.6

Optimizing the delivery of Javascripts on Joomla

Optimizing the delivery of Javascripts on Joomla

We have been working really hard with EasyBlog 5 and while we were optimizing the Javascript portion of EasyBlog 5, we have just realized that Joomla is not able to add gzip compression on most of the scripts which are included in our extension. This results into the file having to be larger than usual.

Since most of these Javascript files are served through it's own absolute URL, the only way to ensure that these files are served with gzip compression is by adding the block of codes below in your .htaccess file or Nginx configuration file:

 

Apache (.htaccess)

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript

 

Nginx

gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

By adding the codes above, we have noticed a great and drastic reduction on your script sizes! Not only does it solve issues with our scripts, any other Javascripts which are served from your Joomla site will automatically gets served with gzip compression as well! On a live site, which I have just tested, adding the codes above reduced a Javascript file from 1.1mb to 260kb. That's almost 450% reductions in size!

NOTE: The codes above would work on any of our extensions and as a matter of fact, it works for any Javascripts being rendered on your site.

Have fun trying this out! I have to get back to the codes right now :)

 

Comments (23)

  1. Justin

Awesome! Thanks Mark.

 
  1. Mark    Justin

No problem Justin! I am greatly impressed at how much savings is added when you use gzip to compress the output.

 
  1. HMED

Thanks Mark, in the htacess i find :
AddOutputFilterByType is now deprecated by Apache. Use mod_filter in the future.

what that mean ? still helpfull to add this line of code in the htaccess file ?

 
  1. Mark

What version of Apache are you currently on right now?

 
  1. HMED

i think apache2 !

 
  1. Mark    HMED

Perhaps you should post your site's details on our forums and I would help you to check on this?

 
  1. HMED    Mark

ok thanks you ;)

 
  1. Ningning Niumai

I don't see any change on my website after adding this in .htaccess!!

am i missing something? I tried testing with http://tools.pingdom.com

 
  1. Mark

Perhaps you already have such codes previously and that is probably why you are not noticing the differences?

 
  1. Joomla dev

Hi

maybe you can step in to Joomla core dev and give them a hand to optimize Joomla core too? :)

That would be good for everyone...:)

 
  1. Mark    Joomla dev

This really has nothing to do with Joomla altogether :p It's just the way the webserver serves the content of the site. Joomla cannot include such codes in their .htaccess because if the webserver doesn't support gzip, it'll fail altogether :(

 
  1. Ningning Niumai

I have simply used the template optimisation option by gavick with exceptions to work with JFC Connect among others. Nothing fancy.

I guess gavick optimisation already does it then. Thanks.

 
  1. Mark    Ningning Niumai

I am not really sure what Gavick Optimizations do for the site but if you want, post a new thread on the forums and I can have a quick inspect on the site for you :)

 
  1. Chris Lewis

Thanks for the info!

 
  1. Mark

No problem Chris :) Glad it helped!

 
  1. Eileen O'Donnell

Thanks for taking a break to share this with us ;)

I found a site that provides a "gzip compression test"; I can't tell if it's legit but here it is if anyone wants to see.

 
  1. Chris Lewis    Eileen O'Donnell

Thanks for the link! Useful

 
  1. Mark    Eileen O'Donnell

Thanks for sharing this Eileen :)

 
  1. Dave Parker

Just in case anyone is running Akeeba Admin Tools, by turning on "Automatically compress static resources" in the .htaccess maker, the same effect is acheived!

 
  1. Mark

Thanks for sharing this Dave :) Didn't know that Admin tools does this as well!

 
  1. Sean Carney

I am glad to find this thread here. I have submitted the code to my host. I have quite a few sites with them and most of them are performing pretty well. But, if this would make them perform even better than I am happy.

Currently I do have one with that uses EasySocial, EasyDiscuss and EasyBlog which has been growing very SLOW. One of the reasons is that I have not been able to get the site to be fast. The pages take six seconds or longer. So, I hope that adding this code might help a...

I am glad to find this thread here. I have submitted the code to my host. I have quite a few sites with them and most of them are performing pretty well. But, if this would make them perform even better than I am happy.

Currently I do have one with that uses EasySocial, EasyDiscuss and EasyBlog which has been growing very SLOW. One of the reasons is that I have not been able to get the site to be fast. The pages take six seconds or longer. So, I hope that adding this code might help a LOT.

Also, I know I have change my homepage to not pull from the various modules of EasySocial, EasyDiscuss and EasyBlog. I was hoping to be able to show people some activity on the home page to entice them to sign up as members.

I previously used other compression tools like JCH-Optimize buth they were causing problems with my scripts and templates. I have the following pages that are all very slow still. (I just turned OFF all caching and the only compression is on my template. Here are the components of my site:

Home Page that pulls dynamic content from multiple components:
https://www.starch-smart.com/
I probably just need to not pull from so many sources?

EasySocial:
https://www.starch-smart.com/social

EasyDiscuss:
https://www.starch-smart.com/forum

EasyBlog:
https://www.starch-smart.com/blog

PS. These pages all are being reported as very slow in GTmetrix, Pingdom Tools and others...

Read More
  Comment was last edited about 3 years ago by Sean Carney Sean Carney
  1. Gary Bashor

I just added this bit of code to my site and it really seems to have made a difference in overall site page load times! Thanks for the tip!

 
  1. Mark

You are most welcome Gary :)

 
There are no comments posted here yet