3

I know JCH Optimize is a very good plugin to compress and minify JS and CSS files but I noticed it also adds time to the page to be rendered.

For example, WITHOUT JCH OPTIMIZE my TTFB is 200ms but WITH JCH OPTIMIZE it's higher (from 5-600ms to 2,5 seconds!)

So I would like to know if you know alternative ways to combine js and css files.

5

JCH Optimize is one of those plugins where you should not simply select everything to be optimised and expect your site to be 2x faster in loading speeds. The more you try and optimise, the more processing the plugin must do.

You may also reach a point, where there is no room for more optimisation.

What I would suggest you do first is only use JCH to minify the JS and CSS files, then compare the page load speed to your initial 200ms. If you see a performance increase, then try combining only JS or only CSS files.

I remember spending literally 3 full days testing loads of plugins, scripts, htaccess with different variations to get the best performance and noticed that over-doing it was not the solution.

  • Thanks lodder, i'm the same guy from the adsense answer. Doesn't JCH Optimize Minify only combined JS and CSS files? Or does it compress them also if they are not combined? – v3ntus Jan 21 '15 at 11:55
  • I haven't used this plugin for a few months so not sure if any of the features have changed, but from what I remember, there was an option to only minify JS or CSS files and another option to combine them too. I believe that combining them is a bigger task to process so try only minifying them first – Lodder Jan 21 '15 at 11:58
  • If I hover on "Minify JS" or "Minify CSS" I see: If Yes, the plugin will remove all unnecessary whitespaces and comments from the COMBINED css/js file to reduce the size for optimized download. – v3ntus Jan 21 '15 at 12:02
  • Yes. Here is an example jQuery uncompressed and jQuery minified – Lodder Jan 21 '15 at 12:08
  • No, I mean: JCH seems to compress only combined js and css files and not the css and js files you have without combining it with jch optimize. In easy words, it should compress js and css only if you combine them using JCH Optimize I think. – v3ntus Jan 21 '15 at 13:26
3

You might also find that using a template.css.php - that enables you to merge all css files and compress them works better:

Code Example: https://github.com/Bloggerschmidt/Blank/blob/master/css/template.css.php

One of the issues with JCH Optimization is that if you use unset code in your template file index.php - so you can include in your template.css.php file eg:

unset($this->_styleSheets[JURI::root(true).'/plugins/system/mijoshopjquery/mijoshopjquery/colorbox/colorbox.css']);

It will still add the code. So - I typically use the JS-CSS Control plugin to stop the css loading:

https://joomla-extensions.kubik-rubik.de/jcc-js-css-control

2

Other alternatives you could use are glup or Grunt. These would work outside of joomla, by setting it up with the files to use.

It would though not easily manage css and js from extensions that JCH would, as it scans the blocks of code on the way in, to the code.

So maybe you will need to decide if your initial page load slower is worth the smaller and less requests that combined files will give you.

1

Stop extensions loading there own css and js and then combine any assets that are actually needed (i.e. 3 x bootstrap.min.css is not needed) in your template, so you're serving 1 minified css and 1 or 2 minified js, both pre-compiled.

This is what I do on almost every build.

Yes, it's a slight pita. Yes, it will make a huge difference to the performance.

Rule of thumb; don't ask the server to do anything you could do beforehand in your local development environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.