WordPress move JavaScript to footer is an easy way to boost page speed. By moving JS to the footer, you let content load first — all with a simple tweak and no plugin needed!
Add this to your child theme’s functions.php
file:
function qdt_move_scripts_to_footer() {
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(‘wp_enqueue_scripts’, ‘qdt_move_scripts_to_footer’);
How It Works
This WordPress move JavaScript to footer snippet removes JS actions from wp_head
and re-adds them in wp_footer
. This ensures scripts load after the main content.
Why WordPress Move JavaScript to Footer?
Moving JS to the footer can improve page speed, better Core Web Vitals, and a smoother user experience — without breaking your theme’s structure.
Common Mistake
Test thoroughly! Some plugins or inline scripts might expect JS in the head. Always check your site after applying this tweak.
Pro Tip
Combine this with deferring or async loading for extra speed improvements.