You’re absolutely right, problem is that different pages load different set of JS/CSS files. Thanks for hint!
What I’m trying to do now is that I create list of all CSS/JS files, that are loaded and I’d like to hard code it into header so autoptimize can make one JS and one CSS file for whole site (or main parts of it as it is quite huge website).
Problem is that when on some page you load twice the same JS/CSS file, autoptimize aggregates it everytime and because of this minimized files are still different (see below).
It would be awesome if while grabbing JS/CSS files from code autoptimize also checks whether these files are already included or not.
Example:
Page #1 loads:
1. url-1/ABC.js
2. url-2/XYZ.js
3. url-1/ABC.js
-> minified js file consists of ABC.js, then XYZ.js and then again ABC.js even though it is the same piece of code from the same file
Page #2 loads:
1. url-1/ABC.js
2. url-2/XYZ.js
So finally there are two minimized .js files that contains both the same skripts only the first one has duplicated content.
I think that checking file URL is what would be great to prevent from minimizing the same file more times.
What do you think – Is it possible or not?