Title: Exclude JS script not working
Last modified: January 18, 2021

---

# Exclude JS script not working

 *  Resolved [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/)
 * Hello,
 * I am trying to exclude a script from being optimized, however, it is not being
   excluded.
    I have added the following to the exclude field in the settings: wp-
   content/plugins/product-delivery-date-for-woocommerce-lite/js/
 * The script is used to select a delivery date, with x number of prep hours. The
   delivery date is not being calculated correctly, however, after manually deleted
   autoptimize cache the delivery dates are calculated correctly.
 * Can you assist with this?
 * Thanks.

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13920360)
 * sure, can you share your site’s URL + the JS error you get on the browser console
   when Autoptimize JS optimization is on?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13925420)
 * I am not getting a specific error, the dates are not calculated correctly.
    The
   next available delivery date should be today + 48 hours. So for example if its
   Monday the next available delivery date should be Wednesday. However, this 48
   hour period is not being calculated correctly. For example on Tuesday it will
   display next available delivery date as Wednesday instead of Thrusday. Once I
   delete autoptimize cache manually it will correctly display the next available
   date as Thursday. Here is the a link where the delivery date could be found: 
   [https://florasent.com/flowers/meadow-fresh/](https://florasent.com/flowers/meadow-fresh/)
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13925686)
 * OK, had a look at the HTML source and the product-delivery-date-for-woocommerce-
   lite JS files are there so the exclusion as such works, but as they are not minified
   AO minifies them. You can stop that by unticking the “also minify excluded CSS/
   JS files” option, at which point you should see product-delivery-date-for-woocommerce-
   lite/js/ in the HTML source again. Can you do so to test if this fixes things?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13930599)
 * Will untick and report back, need to wait for 24 hours to see if it updates correctly.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13931000)
 * if 24 hours then the issue is likely with a nonce being cached by page caching
   having expired antflora, see e.g. [https://docs.wp-rocket.me/article/975-nonces-and-cache-lifespan](https://docs.wp-rocket.me/article/975-nonces-and-cache-lifespan)
   for info on that subject.
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13940806)
 * sorry for the late reply. I should clarify, the reason I said 24 hours is because
   the script updates the next available delivery date based on today’s date. I 
   need to wait until its the next day to make see if the available delivery date
   is calculated correctly.
    -  This reply was modified 5 years, 4 months ago by [antflora](https://wordpress.org/support/users/antflora/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13941282)
 * OK, so with “minify excluded CSS/ JS” off, does the problem still occur?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13946676)
 * Yes, the problem still occurs. I have to manually delete the cache in order for
   the correct delivery date to be calculated.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13946694)
 * This _really_ does smell like a page caching issue to me antflora (the fact that
   is disappears when clearing AO’s cache makes sense, as when cleared AO tries 
   to tell page caching plugins to clear as well). What do you use for page caching?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13946981)
 * I am using Cache Enabler by KeyCDN
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13947317)
 * what is the cache expiry set to?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13947410)
 * It was not set to expire. I have disabled that plugin to see if that is causing
   an issue. What would you recommend to set the expiry at?
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13947763)
 * Also, since I am running woocommerce. Is there anything else I should be excluding
   from Autoptimize to make sure there are no issues?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13947962)
 * re. cache enabler expiry; I would set it to 8h (that _should_ fix any potential
   issues with nonces)
 * re. woocommerce; the safe thing is to disable “also optimize cart/ checkout”
 *  Thread Starter [antflora](https://wordpress.org/support/users/antflora/)
 * (@antflora)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13965870)
 * You’re correct, it was the page cache. I have excluded the product pages from
   being cached in Cache Enabler and the issue is resolved.
 * Thanks for your help!
    -  This reply was modified 5 years, 4 months ago by [antflora](https://wordpress.org/support/users/antflora/).

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

The topic ‘Exclude JS script not working’ 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/)

 * 15 replies
 * 2 participants
 * Last reply from: [antflora](https://wordpress.org/support/users/antflora/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/exclude-js-script-not-working-2/#post-13965870)
 * Status: resolved