While trying to optimize my site loading time, I noticed a big pack of js in the head. After searching, I found a solution:
function remove_head_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( 'wp_enqueue_scripts', 'remove_head_scripts' );
It works fine, all right, but... there are some plugins that include some inline scripts in the body, for example sliders, or another one. So scripts like jquery.js and jquery-migrate.min.js by this function moves to footer, and inline body jQuery text causes many errors.
Is there any way to rewrite the function to exclude some scripts from loading in the footer, like jquery.js and jquery-migrate.min.js?