Title: Javascript optimization set up
Last modified: May 7, 2020

---

# Javascript optimization set up

 *  Resolved [jaromt](https://wordpress.org/support/users/jaromt/)
 * (@jaromt)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-optimization-set-up/)
 * Hi, I’m using [Exit popup](https://wordpress.org/plugins/exit-popup/) plugin 
   to display Contact form 7 form in popup. However, when I activated Autoptimize
   and enabled javascript optimization, plugin stopped working. When I excluded 
   exit-popup script from Autoptimize, unchecked “Minify excluded CSS and JS files?”
   and checked “Force JavaScript in <head>?”, plugin is working again, but pagespeed
   is slower than with javascript optimization disabled and form in popup is not
   showing successful message after submission but page is reloaded without popup.
   Is it possible to set up javascript optimization to make that plugin work correctly?

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12798036)
 * so what happens if you just add `plugins/exit-popup` to the comma-separated JS
   optimization exclusion list but not force JS in head? if it does not work, what
   error(s) are shown on the browser console?
 *  Thread Starter [jaromt](https://wordpress.org/support/users/jaromt/)
 * (@jaromt)
 * [6 years ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12816067)
 * I tried it, but it doesn’t work. There is an error Uncaught ReferenceError: jQuery
   is not defined at <anonymous>:1:1 at CookieControl.Cookie.dequeueNonAsyncScripts(
   uc.js:1) at HTMLScriptElement.a.onload. I think that this error is not related
   to that plugin.
    js/jquery/jquery.js script is also excluded.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12816087)
 * > Uncaught ReferenceError: jQuery
 * does indicate jQuery is not loading early enough though … can you check the page
   source, is it there? does it have an `async` or `defer` attribute?
 *  Thread Starter [jaromt](https://wordpress.org/support/users/jaromt/)
 * (@jaromt)
 * [6 years ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12816508)
 * I finally found where was the problem. jQuery script is deregistered and custom
   jQuery script is enqueued in functions.php file. I excluded that custom jQuery
   script from Autoptimize and now exit popup is showing even with exit-poup.js 
   script not excluded.
    Thanks for your advice.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12816811)
 * good job jaromt 🙂
 * feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂

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

The topic ‘Javascript optimization set up’ 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/)

 * 5 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/javascript-optimization-set-up/#post-12816811)
 * Status: resolved