I am working on new free compression plugin



and need some help in speeding things up. The process of caching is fairly simple ,

  • Get everything in head tag
  • Separate the css files, js files, inline css and inline js
  • Parse all and minify
  • Replace the current head tag contents with new cached one. ( this is trouble )
  • Check log for file changes, if there is change , delete the cache for that page and recreate it.
  • Scan pages in admin back-end for fast cache creation

Everything works , the pages scan , the compression , css image paths replacement , js and css minify , gzip , I mean everything .

Trouble I have with and to me it seems like it is slowing the rendering down is replaceFiles method https://github.com/youjoomla/jcompress/blob/master/jcompress.php#L567

In order to get the head tag contents. I have to do all of this in



All methods you see in the plugin except


https://github.com/youjoomla/jcompress/blob/master/jcompress.php#L567 and



are killed if the cache file exists.

Can anyone take a sec and see if there is something I could do to speed up the replacement of the head contents. And please take a min and test it on your server.

On my local the things are flying. On my live http://stefanstojanovic.com/jcompress/ I see a lag. No bugs , no errors, all cached files created and served. I hope is just my server but I am not sure.

Here are few more test sites http://stefanstojanovic.com/jcompress3/ http://stefanstojanovic.com/jcompress2/

I see a lag on first load , for example here http://stefanstojanovic.com/jcompress3/index.php/breadcrumbs

Next load is 150% faster It "kinda" does make sense since on second load cached css and js is coming from your cache but it should not be such a difference.

Any help is appreciated.

*Update: In meantime I managed to speed it up a bit by only getting the head tag contents instead of the whole body but I still see the lag.

One major difference I also see is between php 5.3 and 5.4 and up. But still no errors on each.

  • 1
    How is this not explaining the issue? prntscr.com/5bq5w3 The pages were slow loading even if the compressed files existed. And how is this a reason for down voting?
    – Dan
    Commented Nov 30, 2014 at 14:42
  • or this for that matter prntscr.com/5bq76u
    – Dan
    Commented Nov 30, 2014 at 14:45

1 Answer 1


Ahhhh! OK so the plugin does work perfect but I used an item id in the hook name for cached file so for 60 menu items you end-up with 60 cached css and js where there is no need for them.

Changing hook name to just count the bytes of exploded css or js files arrays and this way determine if there is difference , makes this plugin fly!

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