How to reduce initial load time
- By removing un-neccessary scripts from header.
- By deferring scripts from header to footer.
1. Which scripts to remove?
In Gtmetrix you will get the following warning:
If you check with Google Page Speed Insights you will get:
Your page has 3 blocking script resources. This causes a delay in rendering your page.
None of the above-the-fold content on your page could be rendered without waiting for the following resources to load. Try to defer or asynchronously load blocking resources, or inline the critical portions of those resources directly in the HTML.
Now in this tutorial we will solve the above issues.
You can remove responsive-menu.js in the following cases:
a. Your site dont have a menu.
b. Your site have a menu with minimum items and there is no sub-menu.
For the above cases you van safely remove this script as follows:
Open functions.php from your theme directory and remove the following line of code.
wp_enqueue_script( 'wbxpress-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
Next you need to remove the following codes from your theme style.css
Remove all the codes under
/* Responsive Menu
Remove all lines of codes inside media only screen containing the following word:
2. Which scripts to Defer?
From the GtMetrix and Google Page Speed result you notice that the jquery is loaded at the time of site loading resulting increased initial loading time. So we can load jquery at the end of site loading. To achieve this you need to add the following function in your functions.php file.