you’re probably aggregating inline JS but your inline JS has page- or request-specific code which busts your cache and that indeed can slow your site down.
possible solutions:
1. don’t aggregate inline JS
2. do aggregate inline JS, but identify what is busting your cache and exclude that from optimization.
there’s more info in the FAQ (and elsewhere in the support forum) on this topic.
hope this helps,
frank
Thread Starter
eddr
(@eddr)
Thanks Frank – you responded way faster than my site..
1. It seems that there was some other problem involved that resulted in 100% CPU which probably related to some other plugin
2. Indeed I aggregate the JS – Are you saying that AO creates a version for different parameters in the JS code? or simply a version for a different code?
don’t think this is the issue, because (3)?
[NGINX issue?]
3. I’ve disabled the following option: “By default files saved are static css/js, uncheck this option if your webserver doesn’t properly handle the compression and expiry.”
Now it seems that the files are gzipped (Apache != NGINX?)
However, multiple versions are created instead of just one version
Thread Starter
eddr
(@eddr)
Also, how can I make compression work for static file mode?
Nothing happens when I use mod_deflate in .htaccess
regarding cache size: if you inline JS (so JS in the HTML, not linked JS-files) contains unique variables/ values that change regularly and you are aggregating your inline JS, then the aggregated JS is different each time, leading to a different autoptimized file. disable the aggregation of inline JS and the problem will disappear.
regarding your other questions:
* (3) has nothing to do with that eddr.
* .htaccess does not work in nginx, you’ll have to check out nginx documentation to learn how to have CSS/JS compressed.
hope this explains,
frank
Thread Starter
eddr
(@eddr)
Thanks
I know NGINX does not use htaccess, but it sits in front of the Apache
in that case;
Nothing happens when I use mod_deflate in .htaccess
check if the mod_deflate module is loaded by apache, without it the .htaccess rules won’t work anyway.
frank
Thread Starter
eddr
(@eddr)
Hi, just a follow-up
Indeed it was an Nginx problem. The Nginx works with Apache and in my case, serves the cache only. I had to activate the gzip related module and add the correct rules – now it works
You might want to add some sentence about it in the docs
Thanks!
Just an idea. why not add an option to add aggregated js in a separate file?
So there would be the js from the header in one file. tje aggregated in a second, the js from after the content (footer) in the third. This way each page would have 2 js files that would be global and a third that is page specific. The site would load faster for repeat visitors as the files would be cached by the browser…
I have something like that on my -long- wish-list actually 🙂
no ETA though, but if you want to help 😉
frank
Would love to help though I barely find time to work on my own stuff with all my clients work but I would like to have a look and see what kind of effort it involves. Also, this is probably the most useful plugin for me so would be happy and honored to add to it. If you point me in the right direction (what part of the code/file/functions/classes) I promise to give it a try!
great!
1st place to start; https://github.com/futtta/autoptimize
File to look into: https://github.com/futtta/autoptimize/blob/master/classes/autoptimizeScripts.php
not entirely sure how to go about, guess you’ll have to store aggregated head-JS, body-JS and inline-JS seperately, minify each one seperately and inject each one seperately. might be quite the rewrite (esp. when taking into account script order which somehow has to be guaranteed).
frank
Thread Starter
eddr
(@eddr)
well, at least for the aggragated inline CSS and JS – these could be separated into an additional file and one could choose where and how they should be included (footer, defer, etc.)
This alone could help a lot and I think it’s easier than taking the all-automatic approach right from the start – what do you think?
Later on, other features could be added
An example, in some of the sites that I’m working on, I had to use the “slider revolution” which add lots of inline CSS. In many pages, the slider is the same and in some it’s not.
I grabbed it. Will hope to have a look at the code soon!