Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

Best Way to Defer Parsing of JavaScript in WordPress

How to Defer Parsing of JavaScript in WordPress

When you check the speed of your WordPress blog, you may get defer parsing of JavaScript. In WordPress, using Async code and  pulling JS code to bottom of page won't help you solve this Defer JavaScript problem. Facebook like box, twitter button, Google + widget and other social sharing buttons will slow down your website speed.

Also see: How to Avoid CSS @Import in WordPress.

The possible solution is loading main content first then JavaScript files.The following code will ensure that all external JavaScript files will be loaded only after the main document is loaded.After adding this code in your child theme's functions.php file, check the website speed in Google Speed Insights, Pingdom and GtMetrix tools.I hope the problem was solved.

function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

Page speed matters a lot in Google search engine rankings.Use only recommended and useful WordPress plugins.Delete unnecessary plugins and install the best cache plugin like W3 total cache or WP Super cache to improve page load time.Of course, with W3 total cache defer parsing of Javascript hardly.This plugin settings are very complex and difficult to understand options.At the end, you will get the best result in page load time with this W3 total cache plugin.

Related Posts

  • WordPress : Remove Transient Options in Database
  • Resources to Minify CSS in WordPress
  • How to Add Infinite Scroll to WordPress Without Plugin
  • How to Add Expires Headers in WordPress
  • How to Inline Small JavaScript Files
  • How to Disable Emojicons in WordPress 4.2
  • How to Add Logo to Twenty Fourteen Theme
  • How to Avoid Landing Page Redirects in WordPress
  • How to Create Custom WordPress Sitemap Without Plugin
  • Top 10 Most Popular Google Adsense Alternatives 2016

Comments

  1. Paul says

    March 24, 2015 at 8:18 am

    Hi,

    I followed your steps, and it worked great.

    I am still having problems with wp-includes/js/jquery/jquery.js

    Any suggestions?

    I used a defer parsing plugin, but added huge size and query string to my website, although defered the file above without issue.

    Thanks

    • Syed Bavajan says

      April 9, 2015 at 5:06 am

      Install Async JS and CSS plugin to completely defer parsing of JavaScript. http://mygenesisthemes.com/async-js-and-css-settings/

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial