• Resolved w4yp01nt

    (@w4yp01nt)


    Hello there πŸ‘‹

    I have a question regarding conditional enqueues, and whether or not Autoptimize honors them?

    I am trying to reduce my page-weight on every single template in my theme, and I am trying to do this, by using conditional enqueues like so:

    function my_enqueue_stuff() {
      if ( is_page( 'landing-page-template' ) ) {
        /** Call landing-page-template-one enqueue */
      } else {
        /** Call regular enqueue */
      }
    }
    add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );

    Does Autoptimize recognize a pattern like this (I’m guessing every template would serve a new bundle) – or is there perhaps another way to achieve this with your plugin?

    Thanks for a great plugin by the way, I have benefited from it on many projects!

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

    (@optimizingmatters)

    hi w4yp01nt πŸ™‚

    Autoptimize works after the enqueues have finished, collecting CSS/ JS from the almost-ready HTML, so your conditional enqueues will be honored. When aggregating this indeed will lead to different bundles per template, so maybe test with “do aggregate but defer”. Assuming you’re on HTTP/2 this might be more efficient.

    enjoy your Sunday!
    frank

    Thread Starter w4yp01nt

    (@w4yp01nt)

    Awesome!

    Thank you, Frank – you enjoy your Sunday too!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Conditional enqueues’ is closed to new replies.