Created
February 5, 2014 11:05
-
-
Save andregomes/8821277 to your computer and use it in GitHub Desktop.
Move JS to wp_footer
From http://www.kevinleary.net/move-javascript-bottom-wordpress/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment