safariright.blogg.se

Wordpress enqueue script defer
Wordpress enqueue script defer








You'd be running preg_replace() on the entire "final" output from Wordpress before it gets sent to the client's browser, for every request. Return preg_replace( "%type=text\/(javascript|css)%", '', $buffer ) īe warned that while this is a solution, it isn't very efficient. If you have offending plugins that don't cooperate (IIRC Jetpack is/was an offender unless a newer version since my recollection has revised this!), and you are adamant about solving this issue despite the fact that your visitors are not likely to be impacted in any way (their browser will render the page fine!), you can always go all-out and use output buffering: add_action('wp_loaded', 'output_buffer_start') Īdd_action('shutdown', 'output_buffer_end')

wordpress enqueue script defer wordpress enqueue script defer

The style_loader_tag and script_loader_tag approaches above look like they should work for whatever markup Wordpress is generating, in cases where the theme/plugin is using the proper enqueue functions. In the red box are coming from W3 total cache.

WORDPRESS ENQUEUE SCRIPT DEFER UPDATE

'/js/custom.js', array( 'jquery' ), '1.1', true ) Ĭan we fix this from the above enqueuing method somehow? Update → We enqueue scripts like this → wp_register_script( 'custom-js', get_template_directory_uri(). These errors are some new introduction by W3C and they have started to creep in last 3-4 days only.

wordpress enqueue script defer

} The type attribute is unnecessary for JavaScript resources.įrom line 441, column 156 to line 441, column 261įrom line 443, column 17 to line 443, column 122 Warning: The type attribute for the style element is not needed and should be omitted.įrom line 11, column 1798 to line 11, column 1820įrom line 23, column 193 to line 23, column 251įrom line 23, column 905 to line 23, column 1010 Warning: The type attribute is unnecessary for JavaScript resources.įrom line 10, column 146 to line 10, column 176








Wordpress enqueue script defer