move javascript to footer

Add below code your WordPress theme functions.php
or try to user wp plugins scripts to footer (this not moves script in the mobile version of mobile.
speed booster pack move all the script but not allows to minify HTML.

/** * Load Enqueued Scripts in the Footer * * 
Automatically move JavaScript code to page footer, speeding up page loading time. */ 
function footer_enqueue_scripts() 
{ remove_action('wp_head', 'wp_print_scripts'); 
remove_action('wp_head', 'wp_print_head_scripts', 9); 
remove_action('wp_head', 'wp_enqueue_scripts', 1); 
add_action('wp_footer', 'wp_print_scripts', 5); 
add_action('wp_footer', 'wp_enqueue_scripts', 5); 
add_action('wp_footer', 'wp_print_head_scripts', 5); } 
add_action('after_setup_theme', 'footer_enqueue_scripts');

Moving javascript footer why it’s important


Other than WordPress  or small HTML pages you can place javascript after closing the </head> and before  closing the </body> tag.

HTML loads first, so the user can see what they want. js Loads meanwhile.

Loading javascript asynchronously and defer parsing js

How to javascript Asynschrounsly?

just look at the Adsense ad code  <script>

<script async src=”path to js file”></script>

How to defer load / parse Javascript?

Defer loading means wait until the  HTML content then load javascript. quick possible solutions use async or defer. but it not works we need use on load function.

this is deep process only for developers. 90% of people ignore this.


Another thing is Optimize CSS Delivery

Minify CSS: Reducing the size by removing comments & Space This process applicable for JS and HTML too.

CSS Placement: why we have to place CSS in the header. Without CSS Plain HTML Loads it looks like ugly.

Inline CSS: if there is small CSS then try to inline the CSS instead loading from external file.


The best Plugin to cache all resources and serve quickly w3 total cache.

Check out my other thoughts Increase page speed score in google insights 95+, How to  improve page speed