10 TOP TIPS FOR OPTIMISING JOOMLA 1.5 FOR SPEED

joomla-logoJoomla! is a fantastic CMS platform that can grow with your needs.  Being an open source system with an ever growing community, Joomla! is going from strength to strength and is being used in more creative ways than ever before.  No matter what type of website you’re looking for Joomla! can handle it.

As Joomla! is molded into the web developers vision using more advanced templates, modules and plugins, it soon becomes a bit of a monster.  Unfortunately that monster is not a speedy one!  The more modules and plugins that are used, the more code is served up to the server, which can start to slow down under the strain.

If the website then becomes popular, or the new development is replacing an old website that already attracts heavy traffic, the results can be disastrous.  In fact, it can result in a blank screen for your visitors.

That doesn’t mean you shouldn’t use Joomla! for successful websites, it simply means you have to plan how you are going to use it and consider several aspects during its build.  To help you do this, I’ve written up a list of checks and optimisation tips that you can use as a basis for your development.

 

1) Use alternative templates for sections
Joomla! takes a bit of getting your head around.  But once you do, you will soon be sorting your content into sections with categories that contain articles.  The point here is that you don’t need to use one single template for the whole website.  By simply copying your template and creating duplicate versions you can apply style-sheets that are needed for that section only.
This will mean less background images from your style-sheets being loaded each time and therefore less overhead.

This will also mean you have the flexibility of altering the template slightly for various areas of the website, which can be really useful from a users perspective as from a navigational point of view, in a large website, they can intuitively know where they are in the website.

To do this simply duplicate your template and rename the template in the xml file.  Click on the new template name in the Joomla! admin template area and allocate the template to the relevant section.

Make sure you point any links to common css files in the new template to the original.  In your new template you then need to point to your extra css template for aspects within this section only.

2) Use css sprites
When you were taught how to design a website in the old days (I’m sounding old now!), you were told to split up images so that theycss could progressively download to show the user something was happening when they were downloading the page.  This was the time of the 56k modem.
While I would say for small sites that attract few visitors you may as well keep this discipline.  For larger sites with big traffic loads I would seriously recommend you use css sprites.
I’m not going to go into detail on how to use css sprites, here’s some great tutorials, but I will tell you why you should use them.

Every-time a user visits your site, all of the background images in your css along with your on-page images are requested from the server.  All of these HTTP requests use a small amount of your servers cpu and memory to deliver the images back to the user.  By combining your images into single images you are cutting down considerably on the number of HTTP requests, therefore saving your server a lot of work.

One tip I will give you that I didn’t see in the tutorials, is that you need 3 types of css sprites.  One for horizontal gradients, another for vertical gradients and a third for single images.  If you are repeating an image in your css on the x axis, you can’s specify a width of an image and repeat it, you need to use the actual full images width.  Therefore if you have several x axis gradients, if you are using css sprites correctly you will have a 1px wide image that is as high as you need to contain all of your gradients.

3) Remove unnecessary javascript from the template
One of the best functions I found in Joomla! was – if (JRequest::getVar(‘view’)!=‘frontpage’) {} , By being able to define if the user is on the front-page (function also works for section or category) you can specify what loads in your template.
Therefore if your website doesn’t need a certain javascript on your front-page but does on sub pages then use this function to remove the script if the user is on the front page.
Let’s face it, we would all like to think that all users are going to love our websites and trawl through all the pages of it.  But in reality many will only load the front page, so lets not make our server work harder than it has to fetching scripts that are not necessary.

4) Remove Mootools.js, Caption.js and K2.js… if you have k2 installed!
logo-mootoolsAlthough you would think that the above function could be used easily to remove mootools.js from loading in the template file, you would be wrong.  Same applies for K2.js if you have the K2 module installed.
The reason for this, is because these javascript files are loaded onto your template via system plugins.
To remove k2.js you need to go into your k2.php file in your plugins -> system folder and edit the script using the function above.
This will make sure your k2.js doesn’t load on the front page.
Mootools.js and caption.js is loaded by default (mostly because your admin pages uses it), so that requires the following script placing at the top of your template…

//remove mootools.js and caption.js
$headerstuff=$this->getHeadData();
reset($headerstuff['scripts']);
foreach($headerstuff['scripts'] as $key=>$value){
unset($headerstuff['scripts'][$key]);
}
$this->setHeadData($headerstuff);

With Joomla! it’s always worth looking at your page’s source code to see what javascript files are being loaded.  Do this on several pages and see if you can identify the modules or plugins that are loading the javascript.  Many modules will use jquery or mootools which are only needed on the pages that have the module active.

5) Deactivate the modules and plugins your not using
When your building a new site with Joomla! it’s easy to get carried away with all the fantastic modules that are available.  Also, before you find that perfect module to fulfill your objective, you may find yourself installing several modules of the same type.
While this is often fine and won’t cause too many problems, there is often a lot of code being injected into your pages due to these deactivatemodules and plugins remaining active.

Therefore throughout your development, install just one module, plugin ot component at a time,  test the new functionality it is suppose to provide and if it doesn’t fulfill your objective un-install it.  It sounds simple, but this discipline will leave your website in good condition.

If you haven’t done this as you go along.  It pays off to go through the modules you are unsure are in use and deactivate them.  Check this doesn’t disable any functionality you want working on the website and un-install if it’s not in use.

6) Have a dig into the third party modules and plugins you’ve installed
The community surrounding Joomla! is fantastic and it never ceases to amaze me just what people are prepared to give away for Programmingfree.  I understand why, as it is a brilliant feeling seeing your product help others, but some of the Joomla! modules and plugins would be the result of years of hard graft and they’re being offered up for free a lot of the time.

However, as with any open source community, the quality of Joomla! extensions do vary.  Some are very code heavy and can cause your site to slow down.  It’s also worth checking the code of a module for third party extensions that may have been used.  For example I’ve spotted a few modues with google analytics embedded.  The author obviously wants to capture how well the module is doing, but this doesn’t help you at all.  So have a dig around, don’t remove code that breaches any copyright, but make sure you understand exactly what the modules doing.

7) Set your expiry tags
Utilising the users cache can be a really useful way of speeding up your website.  Joomla! allows you to set the cache usage up through the admin panel within Site -> Global Configuration -> System.  Depending on how dynamic your site is you can set up how long the cache should be stored before it is refreshed.sell-by-date

While you may set your cache to refresh ever hour, there will still be many components that won’t refresh this often.  By setting expiry tags you are telling the users cache to keep these items for longer periods.

This will again cut down on those valuable HTTP requests as it will only be the first time a visitor views your site will they have to request every element from the server.

To set this up in apache, mod_expires needs to be switched on in the httpd.conf file.  Then within the vhosts section set which file types you want to set expiry tags for, i.e.

ExpiresByType text/css “now plus 1 months”

Here’s a really good article by Simon Whatley on setting up expiry tags.

8) Not Joomla! specific but… Compress your css and javascript files & optimise your images
It may only shave a few milliseconds off, but everything counts.  Obviously the larger the files the more you will benefit from compressing them.
One recommendation though if your compressing fully, is to save an uncompressed version of your css or javascript files so you can easily update them.

photoshop-19-trick

Compressing images used to simply be part of the web build process, but it’s amazing how many web designers now-a-days are looking over this most fundamental of practices.
Invest in a decent package like Photoshop, save your images for web and carefully pick the image that is as optimised as possible while still looking good.  Remember if your designing for mobile to actually view the images on a mobile!  In many cases you can get away with further compression.

http://www.csscompressor.com/ – CSS compression online
http://jscompress.com/ – Javascript file compression online

9) Download YSlow
While Google offers a speed analyser plugin for Firefox, I would recommend downloading YSlow from Yahoo.  It’s a quality plugin thats been around longer than Google’s and while the almighty Google doesn’t often come second, in this case it does.
YSlow will analyse your page, give you stats and let you see by component where your website is optimised and where it’s falling over.
The grading from A-F is instantly available so you can target the problem areas right away.

10) Use your .htaccess file carefully
Again this is not Joomla! specific, but often Joomla! is chosen as a platform when a website is being redeveloped or if this isn’t the case, for sites that are going to grow considerably over time.
When redeveloping a website, you will almost certainly change the structure of your site, therefore popular pages that are linked to and in search engine index’s all over the web, all of a sudden become unavailable.  This can have catastrophic effects on your rankings, visits and ultimately conversions on your website.

Many people turn to their .htaccess file to set 301 redirects for popular pages.  While I would fully recommend you do for the mostjoomSEF_1 important ones, especially those that you have sent out any marketing material for, for those that are less important, leave them be.
By using Google’s webmaster tools, look for pages that are being linked to form external sites, then using Google analytics look for your most popular pages.  Make sure these are set up as 301 redirects.  But set these up in your httpd.conf file instead of your .htaccess file.  By using the httpd.conf file you are ensuring the redirects are loaded once for the users visit rather than every time the user loads any page.  By entering hundreds of 301’s in your .htaccess file you would be making hundreds of server requests for every user visit.  A site that attracts thousands of visits could soon come to a halt.

The same applies for using the .htaccess file to re-write your pages address’s for SEF urls.  Within the Joomla! Global configuration you can use SEF’s without using the apache mod re-write.

Summary

Hopefully some of these tips will help you speed up your Joomla! installation.  But obviously I’ve not covered everything so if you have any more tips please leave them in the comments below to help other Joomla! users that are feeling that need for speed.

Leave a Reply

Your email address will not be published. Required fields are marked *