Title: Failing to load resources when optimizing JS code
Last modified: August 31, 2016

---

# Failing to load resources when optimizing JS code

 *  Resolved [boybawang](https://wordpress.org/support/users/boybawang/)
 * (@boybawang)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/)
 * Hello –
 * Let me start by saying I love your plugin!
 * When I have “Optimize Javascript Code” enabled, some of my pages that run a certain
   plugin don’t work correctly. I went into “developer tools” within chrome, and
   noticed this:
 *     ```
       http://www.skipthedrive.com/wp-content/cache/autoptimize/js/shims/styles/shim.css Failed to load resource: the server responded with a status of 404 (Not Found)
       http://www.skipthedrive.com/wp-content/cache/autoptimize/js/shims/form-core.js Failed to load resource: the server responded with a status of 404 (Not Found)
       ```
   
 * I tried adding jquery.js to the comma separated list of scripts to exclude, but
   that didn’t work.
 * I’m also using CometCache (formerly ZenCache). I disabled that plugin, but still
   had problems.
 * Any suggestions?
 * Thanks
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

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

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-7198216)
 * now as far as the error is concerned: AO never stores files directly in the cache
   directory, but aggregates the files and saves them as “autoptimize_xyz.js or 
   autoptimize_123.css”. this means that the files are being loaded by some javascript
   in a manner that assumes those files (shim.css and form-core.js) are in the same
   directory. as that js itself is optimized, the 2 files are not in the same location
   any more and you get those 404’s.
 * after some looking around it seems it is caldera forms doing this, and more specifically`
   caldera-forms/assets/js/polyfiller.min.js`. try excluding that from JS optimization
   first, but chances are you’ll have to exclude `/caldera-forms/` entirely and 
   maybe `jquery.js` as well.
 * oh and do disable comet cache’s JS and CSS optimization first when using AO, 
   using two minifiers at the same time is asking for trouble 🙂
 * hope this helps,
    frank
 *  Thread Starter [boybawang](https://wordpress.org/support/users/boybawang/)
 * (@boybawang)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-7198316)
 * Hi Frank –
 * Thanks for the quick (and thorough) response. Excluding polyfiller.min.js did
   the trick!
 * Leaving a great review now 🙂
 * Best,
    Pete
 *  [oga23](https://wordpress.org/support/users/oga23/)
 * (@oga23)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244533)
 * hi, i am having the same problem.
    Excluding the polyfiller helped with the majority
   of forms, but one is still not working and i don’t know why.
 * Please help?
 * Link to page: [http://mojzastopnik.si/zavarovanja/zivljenjsko-zavarovanje/osebni-konfigurator/](http://mojzastopnik.si/zavarovanja/zivljenjsko-zavarovanje/osebni-konfigurator/)
   
   The button isn’t working so nobody can enter the form, the background image should
   be full screen and with an overlay…
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244582)
 * this is a difficult one; you have a script template;
 *     ```
       <script type="text/html" id="conditional-fld_6764803_1-tmpl">
       <div class=""><!DOCTYPE html>
       <html>
       <head>
       <title>Font Awesome Icons</title>
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
       </head>
       <body>
   
       <center><i class="fa fa-exclamation-circle" aria-hidden="true" style="font-size:180px;color:red;"></i>
   
       </body>
       </html></div></script>
       ```
   
 * as that template has a `</body>` tag, AO incorrectly injects the autoptimized
   JS at that place, rendering it useless (and probably killing the template as 
   well).
 * try this code to force AO to inject the JS elsewhere;
 *     ```
       add_filter('autoptimize_filter_js_replacetag','oga_js_replacetag',10,1);
       function oga_js_replacetag($replacetag) {
               return array("</footer>","after");
               }
       ```
   
 * hope this helps,
    frank
 *  [oga23](https://wordpress.org/support/users/oga23/)
 * (@oga23)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244610)
 * hi!
    thanks for the supersonic reply!
 * yes, it is the body tag that is causing the problem. i removed it and is working.
   
   But… since the exclamation point is kind of essential for the form,please provide
   me some guidens where to put that code 🙂
 * Thank you.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244617)
 * you can use [the code snippets plugin](https://wordpress.org/plugins/code-snippets/)
   to add the … code snippet I provided 🙂
 *  [oga23](https://wordpress.org/support/users/oga23/)
 * (@oga23)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244619)
 * correction…the bacground image is showing as it supposed to, but the button isn’t
   working when the <body> tag removed…
 * any ideas?
 * thanks
 *  [oga23](https://wordpress.org/support/users/oga23/)
 * (@oga23)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244633)
 * so the functions.php it is 🙂
    i have to many plugins already so i just put the
   code in my child theme functions.php.
 * But…the button is still not working so it should be something more that is bothering
   my form.
 * What about the excludes js’s?
 * i was experimenting and added all of these:
    caldera-forms/assets/js/handlebars.
   baldrick.js, caldera-forms/assets/js/handlebars.js, caldera-forms/assets/js/polyfiller.
   min.js, caldera-forms/assets/js/modals.baldrick.js, caldera-forms/assets/js/jquery.
   form-validator.min.js, caldera-forms/assets/js/jquery.form-validator.js, caldera-
   forms/assets/js/caldera-modals.min.js, caldera-forms/assets/js/caldera-modals.
   js, caldera-forms/assets/js/frontend-script-init.min.js, caldera-forms/assets/
   js/frontend-script-init.js, caldera-forms/assets/js/html5.js, caldera-forms/assets/
   js/ajax-core.min.js, caldera-forms/assets/js/ajax-core.js
 * 🙂
 * i guess that is not right either… 🙂
 * thank you for your help.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244676)
 * well, you could try removing all excludes (except if you’re sure you need them)
   OR add `js/jquery/jquery.js` to the list (as you have “ReferenceError: jQuery
   is not defined”)
 * frank
 *  [oga23](https://wordpress.org/support/users/oga23/)
 * (@oga23)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8244753)
 * well, i’m not sure of everything since i don’t know anything about this, really
   🙂
 * but – i added js/jquery/jquery.js and everything is fine now!!!
 * thank you thank you thank you thank you thank you !!!!
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8245787)
 * super! 🙂

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

The topic ‘Failing to load resources when optimizing JS code’ 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/)

## Tags

 * [Failed](https://wordpress.org/support/topic-tag/failed/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [js](https://wordpress.org/support/topic-tag/js/)
 * [load](https://wordpress.org/support/topic-tag/load/)

 * 11 replies
 * 3 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/failing-to-load-resources-when-optimizing-js-code/#post-8245787)
 * Status: resolved