Title: Conditional script enqueue per page?
Last modified: August 30, 2016

---

# Conditional script enqueue per page?

 *  Resolved [Steven Vachon](https://wordpress.org/support/users/prometh/)
 * (@prometh)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/conditional-script-enqueue-per-page/)
 * Is it easily possible to only link to the script when/if the page has an active
   A/B test running? There’s not much sense in forcing the script to download on
   every page.
 * [https://wordpress.org/plugins/optimizely/](https://wordpress.org/plugins/optimizely/)

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

 *  Thread Starter [Steven Vachon](https://wordpress.org/support/users/prometh/)
 * (@prometh)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/conditional-script-enqueue-per-page/#post-6787168)
 * Something like this could be added to optimizely.php:
 *     ```
       if (get_post_meta(get_the_ID(), 'optimizely_experiment_status', true) != 'Running') {
   
       }
       ```
   
 * …but such changes would be lost on the next update.
 *  Plugin Author [moravemj](https://wordpress.org/support/users/moravemj/)
 * (@moravemj)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/conditional-script-enqueue-per-page/#post-6787397)
 * We can’t know if an experiment is running on the page until after the Optimizely
   script is downloaded and run. This is because we evaluate on every page load 
   whether to run the experiment or not.

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

The topic ‘Conditional script enqueue per page?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/optimizely_004a69.svg)
 * [Optimizely Classic](https://wordpress.org/plugins/optimizely/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/optimizely/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/optimizely/)
 * [Active Topics](https://wordpress.org/support/plugin/optimizely/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/optimizely/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/optimizely/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [moravemj](https://wordpress.org/support/users/moravemj/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/conditional-script-enqueue-per-page/#post-6787397)
 * Status: resolved