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=".min.js' defer onload='"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=".min.js' defer onload='"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=".min.js' defer onload='"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=".min.js' defer onload='"></scr' + 'ipt>' );
This question already has answers here:
WordPress v5.0.3 Gutenberg & JS error "Uncaught SyntaxError: missing ) after argument list"
(3 answers)
Closed 5 years ago.
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/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js' defer onload='"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src="https://learn.blueworkforce/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/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/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js' defer onload='"></scr' + 'ipt>' );
Share
Improve this question
edited Feb 18, 2019 at 15:16
Max Yudin
6,3882 gold badges26 silver badges36 bronze badges
asked Feb 18, 2019 at 15:10
jn bluejn blue
11 bronze badge
2
|
2 Answers
Reset to default 0You 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.
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.
SCRIPT_DEBUG
is set – Tom J Nowell ♦ Commented Feb 18, 2019 at 15:31