• [email protected]

    (@michaelratcliffefamilyorg)


    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.