• I’m using a theme right now (https://wordpress.org/themes/sento/) that only loads some JS/CSS files when it needs them.

    Examples:
    – On the homepage the JS/CSS for the slider are loaded but not on the other pages.
    – On pages that have a sidebar a specific CSS is loaded but not on the other pages.

    This causes Autoptimize to create several JS/CSS files depending on what each page loads.

    What would you do usually do on these cases?
    – You let things as they are and the user will load different combined JS/CSS files depending on the current page being visited (smaller files but several need to be loaded)
    or
    – You make sure all the needed JS/CSS files are enqueued on every pages so that Autoptimize will create a unique JS and CSS file that is valid for all the website (bigger file but only needs to be loaded once)

    https://wordpress.org/plugins/autoptimize/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Frank Goossens

    (@futtta)

    In general (and exceptions not withstanding) you’ll have 4 types of pages that could have different CSS/JS (as they have their own templates):
    * homepage
    * individual blogposts
    * blogpost overviews (archive, search, …)
    * pages

    In this case, I would go for “You let things as they are and the user will load different combined JS/CSS files depending on the current page being visited”.

    If however there is extra logic that results in the optimized CSS or JS being really different on each and every page, then I would try to exclude the unique code, much as explained in the FAQ under “My cache is getting huge, doesn’t Autoptimize purge the cache?”.

    Hope this clarifies,
    frank

    Thread Starter Marco Almeida | Webdados

    (@webdados)

    Hi Frank,

    (now, that was fast)

    I forgot to mention that 3rd option of excluding the variable files.

    In the meanwhile I’ve launched this discussion on the “Advanced WordPress” group on Facebook to see what different developers would do. https://www.facebook.com/groups/advancedwp/permalink/1000790676649813/

    Thank you for your excellent support, as always.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Themes that use variable number JS and CSS files’ is closed to new replies.