Title: Conditional enqueues
Last modified: May 2, 2021

---

# Conditional enqueues

 *  Resolved [w4yp01nt](https://wordpress.org/support/users/w4yp01nt/)
 * (@w4yp01nt)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/conditional-enqueues/)
 * 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](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/conditional-enqueues/#post-14388884)
 * 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](https://wordpress.org/support/users/w4yp01nt/)
 * (@w4yp01nt)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/conditional-enqueues/#post-14389071)
 * 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.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [w4yp01nt](https://wordpress.org/support/users/w4yp01nt/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/conditional-enqueues/#post-14389071)
 * Status: resolved