Add Defer and Async Attributes to Render Blocking Javascript in wordpress without plugin

Share us

How to Add Defer and Async Attributes to Render Blocking Javascript

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to to Add Defer and Async Attributes to Render Blocking Javascript

function js_async_attr($tag){

# Add async to all remaining scripts
return str_replace( ‘ src’, ‘ defer=”defer” src’, $tag );
}
add_filter( ‘script_loader_tag’, ‘js_async_attr’, 10 );

This will Add Defer and Async Attributes to Render Blocking Javascript in wordpress without plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

Share-ask.com

Help Save www.Share-Ask.com future by donating any amount to our paypal id admin@share-ask.com ASAP

You may also like...