• Resolved rom174

    (@rom174)


    Hello,

    I made this observation :

    The concatenated autoptimized css and js files are different for each page. The result is that each visited page loads a non cached autoptimize css and js file.
    In my case the transfered size over network is on average 230kb (css) and 125kb (js). For each page the difference is around 2kb, so it gives this when browsing site :

    1st visited page :
    css : autoptimize_1111111111.css –> 231kb
    js : autoptimize_1111111111.js –> 124kb

    2nd visited page :
    css : autoptimize_2222222222.css –> 229kb
    js : autoptimize_2222222222.js –> 124kb

    3rd visited page :
    css : autoptimize_3333333333.css –> 232kb
    js : autoptimize_3333333333.js –> 126kb

    …. and so on.

    From there I am not sure about 2 things, are those statements true ? :

    -The difference is because the styles and scripts are not the same depending of the page so the concatenated files differ in order to include page specific code.

    -It works this way because if we had one common file for the full site, this 2kb difference would make this common css/js file +2000kb if there are 1000 pages.

    If those statements are true, here is what I am wondering :

    Would it be possible to generate one common css/js file for the entire site AND for instance, inlining the specific code in the head/footer or generating a 2nd specific css/js file in order to efficiently use the browser cache and not reload 99% of the already loaded code ?
    This way of handling files would give :

    1st visited page :
    common css : autoptimize_common.css –> 225kb
    common js : autoptimize_common.js –> 120kb
    specific css : autoptimize_1111111111.css –> 6kb
    specific js : autoptimize_1111111111.js –> 4kb

    2nd visited page :

    common css : autoptimize_common.css –> 225kb – cached, not reloaded
    common js : autoptimize_common.js –> 120kb – cached, not reloaded
    specific css : autoptimize_2222222222.css –> 4kb
    specific js : autoptimize_2222222222.js –> 4kb

    3rd visited page :

    common css : autoptimize_common.css –> 225kb – cached, not reloaded
    common js : autoptimize_common.js –> 120kb – cached, not reloaded
    specific css : autoptimize_3333333333.css –> 7kb
    specific js : autoptimize_3333333333.js –> 6kb

    …. and so on.

    Is it possible to do this ?
    What are the limitations/issues of handling css/js generation this way ?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    AO indeed simply aggregates what it finds in the HTML it optimizes taking into account the configuration (exclusions). As AO works on request/response level, it has no idea of what JS or CSS is common between all pages/ posts/ archives on a site.

    Generally the safe approach is not aggregating inline JS (default off) and if need be not aggregating inline CSS either (which is on by default). Additional configuration might be needed to ensure maximum re-usability of one Autoptimized JS/ CSS file over large portions of a site.

    Using something like “plugin optimizer” to do fine-grained plugin deactivation on specific pages on the site in this context might also make JS/ CSS aggregation less efficient as those exclusions can lead to JS/ CSS being different as well, so that is to be used sparingly.

    Thread Starter rom174

    (@rom174)

    Thank you for the fast reply.

    Exclusion is not really a workaround as it will be loaded individually, not concatenated and make 1 ressource more in the pages requesting it.

    Additional configuration might be needed

    What/where is this configuration ?

    to ensure maximum re-usability of one Autoptimized JS/ CSS file over large portions of a site.

    Not sure what does it mean ? If every generated css/js files are unique/single to every page, where is the common code generated/used over large portions ?
    With this config, 2 different pages can already use the same autoptimize css/js file ?

    it has no idea of what JS or CSS is common between all pages/ posts/ archives on a site.

    If it has no idea of other used common css/js, how does the maximum re-usability works ?

    Indexing class used in previous concatenated file with, for instance with a treshold of common page/portion in order to compare, at the next css/js autoptimize file, put it in a ‘common’ or a ‘specific’ file could work ? Would it be useless or be consumming too much server ressources ?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    What/where is this configuration ?

    The CSS & JS optimization exclusion fields + the option to aggregate inline CSS/ JS ??

    With this config, 2 different pages can already use the same autoptimize css/js file

    all depends on your site and the autoptimize configuration, in my site most autoptimized files are indeed reused on most pages ??

    If it has no idea of other used common css/js, how does the maximum re-usability works ?

    by configuration ??

    Indexing class used in previous concatenated file with, for instance with a treshold of common page/portion in order to compare, at the next css/js autoptimize file, put it in a ‘common’ or a ‘specific’ file could work ? Would it be useless or be consumming too much server ressources ?

    well, it would most certainly require a serious rewrite of how AO now works. if you have time & some PHP coding experience feel free to take a stab, if all works well I’d be happy to merge a PR ??

    Thread Starter rom174

    (@rom174)

    all depends on your site and the autoptimize configuration, in my site most autoptimized files are indeed reused on most pages

    Do you mean reused with the exact same file to end up using the browser cache from page to page instead of reloading associated css/js autoptimize file ?
    Just to be sure, on your site, if one page uses a class that is not present in other pages, will it generates a new css file with same content + this new class and then load this autoptimize css file as if the ‘same content’ wasn’t already in the browser cache ?

    Sorry for those questions, I am wondering if my site is correctly set up and if I correctly use AO. Depending of your answer I will have to re-setup my site config because it would mean what I want to achieve is already possible.

    well, it would most certainly require a serious rewrite of how AO now works. if you have time & some PHP coding experience feel free to take a stab, if all works well I’d be happy to merge a PR ??

    So for you, who has developed the plugin, this could be a true working direction of improvement ? Anyway, I won’t be able to do this but I can suggest it to a dev team yes.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Just to be sure, on your site, if one page uses a class that is not present in other pages, will it generates a new css file with same content + this new class and then load this autoptimize css file as if the ‘same content’ wasn’t already in the browser cache ?

    no; AO does not work on the level of classes. either the CSS on a page is in the autoptimized CSS file or it is not (by exclusion). if it is not in the autopimized CSS file it is loaded as is.

    So for you, who has developed the plugin, this could be a true working direction of improvement ? Anyway, I won’t be able to do this but I can suggest it to a dev team yes.

    yes, the idea of having “bundles”, with one Autoptimized JS (or CSS) file that is used throughout the site and one Autoptimized JS (or CSS) file for non-common code could be an interesting approach ??

    Thread Starter rom174

    (@rom174)

    Sorry, I probably mispoke and not sure to understand, so after this message I will stop.

    What I wanted to understand more widely (than the classes level) is : on your site, how can you use the same AO files with 2 or more pages :

    Is the CSS & JS optimization exclusion fields + the option to aggregate inline CSS / JS you advise the only way to trigger the ao_1.css and ao_1.js generation for page_1.html and then, saying to page_2.html to use ao_1.css and ao_1.js instead of generating it ?

    Depending of the unicity of pages + the number of plugins and where/how it is used on the site, won’t it be a very specific combination of settings that I am afraid will make AO lose its already pretty good efficiency ?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    this is getting a tad too theoretical rom174 but yes, the settings (exclusions + “also aggregate inline” are the only way to influence if a new cached file gets created or not.

    in my experience esp. if “also aggregate inline” is off, there is a lot of reuse of the same autoptimized JS/ CSS accross different pages ??

    Thread Starter rom174

    (@rom174)

    Well, thank you very much for your answers, your patience and your plugin !

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome rom174 ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘1 css/js files per page VS 1 css/js files per site’ is closed to new replies.