Today, We want to share with you defer parsing of javascript htaccess.In this post we will show you
defers parsing of javascript wordpress w3 total cache, hear for defers parsing of javascript autoptimize we will give you demo and example for implement.In this post, we will learn about Top 10 Best PHP Code Optimization Techniques with an example.
defer parsing of javascript Examples
Contents
Example 1: Defers
<script defer src="customMainScrpt.js" onload="myInit()"><script>
Async
<script async src="customMainScrpt.js" onload="myInit()"><script>
Parse js/css as a PHP file using htaccess
Example 2:
<FilesMatch "\.(js)$"> AddHandler application/x-httpd-php .js </FilesMatch>
defer parsing of javascript wordpress
Example 3: Defers JavaScript via functions.php File
Plugins & Theme Async/Defers Parsing of JavaScript
// Only for Javascript 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.js' ) ) return $url; return str_replace( ' src', ' defer src', $url ); } add_filter( 'script_loader_tag', 'defer_parsing_of_js', 10 );
Difference between async and defer
The difference between async and defer centers around when the script is executed.
I hope you get an idea about defers parsing of javascript wp rocket.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.