0

I'm getting this error when loading my page. I have 5.0.3 of WordPress.

Uncaught SyntaxError: missing ) after argument list
:formatted:1845

The link redirect to this code:

<script type='text/javascript'>( 'fetch' in window ) || document.write( '<script src="https://learn.blueworkforce.com/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js' defer onload='"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src="https://learn.blueworkforce.com/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js' defer onload='"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src="https://learn.blueworkforce.com/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js' defer onload='"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src="https://learn.blueworkforce.com/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js' defer onload='"></scr' + 'ipt>' );

2
  • This is core.trac.wordpress.org/ticket/46110 that file is only loaded if SCRIPT_DEBUG is set
    – Tom J Nowell
    Commented Feb 18, 2019 at 15:31
  • The code posted fails before the wp-polyfill-formdata is run. For whatever reason the script output is broken. (possibly filtered by something) It will fail on all browsers.
    – Tim
    Commented Mar 29, 2019 at 15:28

2 Answers 2

0

You have the same error repeated on each script. Look at the attribute delimiters. They start using double quotes, then switch:

<script src="https://...js' defer onload='">
                          ^              ^

Should be:

<script src="https://...js" defer onload="">

The first single quote I've marked, ends the enclosing string. That's not invalid, but not what is intended. Everything after that point is just waiting for a syntax error to occur.

I don't know how these mistakes ended up in your code, but I note that they are not as the WordPress core outputs the scripts normally.

My guess is that the following string has been spliced into the script output expecting that single quotes would be used.

' defer onload='

Possibly some plugin is doing this to all scripts with some filter, possibly Mos Speed up which seems to do this.

0

The problem is due to WordPress Gutenberg's some js which doesn't support defer. I had the same problem, I have added a WordPress hook to defer js. I have added a condition now that the hook will not call on admin pages and it fixed my issue.

OLD code:

add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

New code:

if ( !is_admin() ) {
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
}

after this code, it is not adding defer to admin side scripts and it saved me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.