Using the Yireo ScriptMerge plugin
The Yireo ScriptMerge plugin allows you to optimize your Joomla! HTML-output by merging CSS-stylesheets and JavaScript-files together as one, and therefor limiting the number of HTTP-requests needed to load the page. The plugin uses an extra component for added functionality. This tutorial shows you how to implement ScriptMerge.
Installation
- Download both the ScriptMerge plugin as the ScriptMerge component from the download-section on this site.
- Install both ZIP-files from within the Joomla! Administrator as regular extensions.
- Next go to the Plugin Manager to enable the system-plugin. It is listed as "System - ScriptMerge".
- Make sure the ScriptMerge plugin is loaded as one of the last plugins - give it a high ordering number (for instance 99).
- Make sure the Joomla! cache directory is writable for the webserver.
General usage
The plugin parameters allow you to enable or disable compression of either CSS or JavaScript. Compressing CSS is generally a good idea and again saves some bandwidth. Compressing JavaScript could be troublesome if third party scrips are written with non-standard code. You need to experiment with the settings to find out which settings are right.
Tuning ScriptMerge might also require you to know which CSS and which JavaScript is loaded for which purpose. If you are able to study the HTML-source, you know the possibillities of tweaking ScriptMerge to the max. If you are not familiar with HTML-sources, you should probably hire a developer to optimize performance for you.
ScriptMerge makes use of the general Joomla! cache. If you want to clean the ScriptMerge cache you can navigate to Tools > Clean Cache in the Joomla! backend.

Plugin parameters
Through the Joomla! Plugin Manager, you can manage the settings of the ScriptMerge plugin. The following parameters are available:
- Merge Type: This can be set either to Checksum or Filelist. The default value is set to Checksum and this works fine in most environments. If you wish to implement full page caching, you will need to choose the option Filelist - but note that this issue could cause issues. See the known issues below, when you run into problems.
- Merge CSS: This option is the main functionality of ScriptMerge, and should probably be set to Yes.
- Merge JS: This option is the main functionality of ScriptMerge, and should probably be set to Yes.
- Compress CSS: The better compressed CSS is, the faster the page will load. However, third party extensions or the template might add CSS-code that is causing problems. Make sure the CSS is W3C compliant when enabling this option.
- Compress JS: Enabling this option gives as well added performance, but should be handled with care. In some cases, JavaScript files from various third party extensions cause this option to break all JavaScript on your pages. If you enable this option, make sure to check all your pages for JavaScript errors.
- Exclude CSS: This is a comma-seperated list of CSS-files to exclude from the merge-process.
- Exclude JS: This is a comma-seperated list of JS-files to exclude from the merge-process.
- Enable in backend: The speed of the Joomla! Administrator can be improved as well, by enabling this option. However, some third party extensions might add CSS and JS that causes problems, effectively locking you out of the backend. Be careful when using this option, and make sure you know how to modify the ScriptMerge plugin parameters by using SQL-commands (for instance, through phpMyAdmin).
- Enable in Frontend: This defaults to Yes, because you most likely want to improve your site-speed for visitors. In rare cases,
- Enable in Backend: This defaults to No, and should be handled with care.
The ScriptMerge component is not accessible from the Joomla! backend and contains no parameters.
Notes on JavaScript compression
The JsMinPlus library included with ScriptMerge allows for best compression of JavaScript-files. The alternative is to compress JavaScript with simple PHP-rules, or not compress it at all. The downside of JsMinPlus is that is quite slow. Do not use it with the Merge Type set to Filelist, because this will run JsMinPlus on every page-request. Note that JsMinPlus is not compatible with MooTools - so ScriptMerge automatically applies the simple compression when finding a file with the word mootools in it.
Known issue: Unable to access site
You might have installed ScriptMerge and started playing with it. Sure this is possible, but with a valid backup, right? And on a testing environment, right? If no, something really is wrong with the procedure to safeguard your site. Anyway, if you have played with some settings: For instance, enabling ScriptMerge for the backend sounds really cool. But there are tons of experimental options that might or might not work, and if they do not work, they might cause your backend to stop working. Nothing unexpected.
Solution: Restore your backup. If you don't have a backup, that's your real problem. As a last resort, try removing the ScriptMerge plugin-files from the Joomla! folder system/plugins. After you have gained access to your Joomla! backend, remove the ScriptMerge extension. Optionally reinstall it. Create a backup first.
Known issue: Full page caching
ScriptMerge gives problems with mechanisms that use full-page-caching (Joomla! Page Cache plugin, JotCache plugin). These mechanisms cache the entire page, including the HTML-header which contains the links to the merged ScriptMerge cachefiles. But if the ScriptMerge cachefiles expire and are removed before the full page cache expires, the full-page-cache refers to ScriptMerge cachefiles which are not there any more. This results in a broken page with no CSS and JavaScript.
To use ScriptMerge together with full page caching, you need to set the option Merge Type to Filelist instead of Checksum. Note that this causes all CSS-files and JS-files to be passed as an argument to the ScriptMerge component. Some webservers limit the URL-length, causing problems here.
Known issue: Third party SEF extensions
When the ScriptMerge option Merge Type is set to Filelist, the ScriptMerge component is activated and called through a Joomla! URL. When using third party SEF extensions, the original System URL is modified by that extension. Most likely that third party SEF extension has bad support for the ScriptMerge component. Therefor, modify the SEF extension to exclude the ScriptMerge component. If such an option is not available in the SEF extension, switch the Merge Type option to Checksum or choose a different SEF extension.
Known issue: Not all CSS is available in the Filelist
If a CSS-file is choosen to be included in the merging process, but that CSS-file is not ending with the css file-extension (example.css), that file will not be outputted by ScriptMerge when setting the Merge Type to Filelist. If this is the case, change this option to Checklist instead.
With JavaScript-files, the same applies for the js file-extension. This limitation is intended functionality, to prevent remote file inclusion.
Created on Monday, 03 October 2011Modified on Tuesday, 19 February 2013