Title: Async JavaScript plugin breaks core WordPress Scripts
Last modified: August 20, 2020

---

# Async JavaScript plugin breaks core WordPress Scripts

 *  [michael@ratcliffefamily.org](https://wordpress.org/support/users/michaelratcliffefamilyorg/)
 * (@michaelratcliffefamilyorg)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/async-javascript-plugin-breaks-core-wordpress-scripts/)
 * Wordpress v5.5
    WooCommerce v4.4.1 Async JavaScript v2.20.03.01
 * STR:
 * 1. Enable Async JavaScript: Enabled.
    2. Async JavaScript Method: Defer. 3. jQuery:
   Exclude.
 * Load the product catalogue or any product page and the following error is thrown.
 * `Uncaught SyntaxError: missing ) after argument list mydomain.com:2774:57`
 * This is the Core WordPress script throwing the error because it is broken by 
   the Async JavaScript plugin (the single quotes in ‘defer’ break it):
 *     ```
       <script type='text/javascript' id='wp-polyfill-js-after'>
           ('fetch' in window) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0"></scr' + 'ipt>'); (document.contains) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.42.0"></scr' + 'ipt>'); (window.DOMRect) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.min.js?ver=3.42.0"></scr' + 'ipt>'); (window.URL && window.URL.prototype && window.URLSearchParams) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-url.min.js?ver=3.6.4"></scr' + 'ipt>'); (window.FormData && window.FormData.prototype.keys) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js?ver=3.0.12"></scr' + 'ipt>'); (Element.prototype.matches && Element.prototype.closest) || document.write('<script defer='defer' src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2"></scr' + 'ipt>');
       </script>
       ```
   
 * Here is the same script with Async JS disabled (throws no errors):
 *     ```
       <script type='text/javascript' id='wp-polyfill-js-after'>
           ( 'fetch' in window ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.42.0"></scr' + 'ipt>' );( window.DOMRect ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.min.js?ver=3.42.0"></scr' + 'ipt>' );( window.URL && window.URL.prototype && window.URLSearchParams ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-url.min.js?ver=3.6.4"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js?ver=3.0.12"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src="https://mydomain.com/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2"></scr' + 'ipt>' );
       </script>
       ```
   
 * Why the heck they are still using `document.write` to inject scripts in this 
   day and age I don’t know.

The topic ‘Async JavaScript plugin breaks core WordPress Scripts’ is closed to new
replies.

 * ![](https://ps.w.org/async-javascript/assets/icon-128x128.png?rev=1839260)
 * [Async JavaScript](https://wordpress.org/plugins/async-javascript/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/async-javascript/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/async-javascript/)
 * [Active Topics](https://wordpress.org/support/plugin/async-javascript/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/async-javascript/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/async-javascript/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [michael@ratcliffefamily.org](https://wordpress.org/support/users/michaelratcliffefamilyorg/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/async-javascript-plugin-breaks-core-wordpress-scripts/)
 * Status: not resolved