Great question — answering as the UphillTech team:
It is necessary to exclude defer addition for files that have -js-after In my case, the error was caused by the files hooks.min.js and i18n.min.js . This function worked great in my case: function defer_parsing_of_js( $url ) { if ( is_user_logged_in() ) return $url; //don't break WP Admin if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, "jquery.min.js" ) || strpos( $url, "jquery-migrate.min.js" ) || strpos( $url, "hooks.min.js" ) || strpos( $url, "i18n.min.js" )) { return $url; } return str_replace( ' src', ' defer src', $url ); } add_filter( 'script_loader_tag', 'defer_parsing_of_js', 10 );
Full answer by Boris Michourin: https://wordpress.stackexchange.com/a/427603 (CC BY-SA 4.0).
Need it done for your business? UphillTech.