JCH outputs the combined and compressed CSS file as:


Since this is a randomly generated link every time JCH refreshes the file, is there a way to retrieve the URL programmatically?

I am thinking something like this URL would allow me to reference the CSS file from outside the Joomla! environment (this is just for reference as I realize it would never work as written):


The CSS reference is redirected to a PHP file:


The contents of that file are:

require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/plugins/system/jch_optimize/bootstrap.php';



1 Answer 1


Good question. Looking at a different approach, you could use PHP to get all the CSS files in the given directory and then import them.

Something like so:

$dir = 'media/plg_jchoptimize/assets/gz/1/0/*.css';

foreach (glob($dir) as $css)
    echo "<link rel='stylesheet' href='$css'>\n";

This is of course assuming that the website that's outside of your Joomla environment is on the same server

  • Great thinking outside the box! Unfortunately, these are not actual files that are stored on the server--they're just redirects to a file generated by PHP. However, that did get me thinking about calling the PHP directly. I have updated the question with info on that. Commented Aug 2, 2017 at 16:01
  • @MichaelYaeger what do you have Combined Files Delivery set to in the plugin options? Just so I can try and replicate this.
    – Lodder
    Commented Aug 2, 2017 at 16:18
  • I'm using the "Optimum" automatic settings group Commented Aug 2, 2017 at 17:05
  • Spent a while looking through the plugin code and there are so many functions in so many files. Unfortunately I wasn't able to figure it out, but I believe that if you set Combined Files Delivery, you'll be able to use the code (changing the path of course) in my answer
    – Lodder
    Commented Aug 2, 2017 at 18:21
  • OK, I'll give it a go and see... Commented Aug 2, 2017 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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