WP 5.3 and deferring JavaScript files
-
Hello. For several years I’ve had custom PHP code on my site which ensured all JavaScript files (except jquery.js) were deferred during page load. Prior to WP version 5.3, the code resulted in no front-end issues, or JavaScript console errors. Furthermore, page speed checkers like Google’s PageSpeed Insights confirmed that the JS files were sufficiently deferred, and not slowing down page load. The code is at the bottom of this post.
But after updating to WordPress version 5.3, this code now results in many JavaScript console errors (screenshot). Just about all of the errors seem to be related to WordPress core files. If I remove the custom PHP code, the JS console errors do not appear. But conversely, my page load time seems to increase significantly because these files are no longer deferred.
Does anyone know why this change has occurred? Did version 5.3 move code around (or add new code) so that I can no longer defer the loading of some of these core JS files?
Thanks in advance.
___
**My PHP Code**function hh_defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url;// Skip all non .js files. if ( strpos( $url, 'jquery.js' ) ) return $url;// Skip jquery.js. return "$url' defer onload='"; } add_filter( 'clean_url', 'hh_defer_parsing_of_js', 11, 1 );
The page I need help with: [log in to see the link]
- The topic ‘WP 5.3 and deferring JavaScript files’ is closed to new replies.