FIX PROPOSAL: async or defer append
-
Hi!
In the aj_async_js function of the AsyncJavaScriptFrontend class the insertion of the async and defer parameters should be changed in this way:
ROW 104
$tag = str_replace( 'src=', $aj_jquery . '="' . $aj_jquery . '" src=', $tag );
ROW 115
return str_replace ('src =', 'async = "async" src =', $ tag);
ROW 125
return str_replace ('src =', 'defer = "defer" src =', $ tag);
to avoid that the insertion of these parameters inside javascript code generates unexpected errors.
This is easily verified when loading the wp-admin page and checking the insertion of the “wp-polyfill-js-after” js.
The current result is as follows:( 'fetch' in window ) || document.write( '<script async='async' src="https://www.invent-biomedical.it/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js?ver=3.0.0"></scr' + 'ipt>' );( document.contains ) || document.write( '<script async='async' src="https://www.invent-biomedical.it/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js?ver=3.42.0"></scr' + 'ipt>' );( window.DOMRect ) || document.write( '<script async='async' src="https://www.invent-biomedical.it/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 async='async' src="https://www.invent-biomedical.it/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 async='async' src="https://www.invent-biomedical.it/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 async='async' src="https://www.invent-biomedical.it/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js?ver=2.0.2"></scr' + 'ipt>' );
which causes the error:
Uncaught SyntaxError: missing) after argument list
Regards.
- The topic ‘FIX PROPOSAL: async or defer append’ is closed to new replies.