How to move the jQuery in the footer?
-
Hello,
I have a problem with moving jquery via CDN, I’ve tried many solutions in this forum and on Stack Overflow but I can’t find a solution to migarate the script in the footer.I currently use the following code to invoke the script:
add_action('wp_enqueue_scripts', 'load_jquery'); function load_jquery() { global $wp_scripts; if(is_admin()) return; $wp_scripts->registered['jquery-core']->src = 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'; $wp_scripts->registered['jquery']->deps = ['jquery-core']; }
This below is one of the many scripts found in the form to be able to move the jquery into the footer but it doesn’t work:
function jquery_mumbo_jumbo() { wp_dequeue_script('jquery'); wp_dequeue_script('jquery-core'); wp_dequeue_script('jquery-migrate'); wp_enqueue_script('jquery', false, array(), false, true); wp_enqueue_script('jquery-core', false, array(), false, true); wp_enqueue_script('jquery-migrate', false, array(), false, true); } add_action('wp_enqueue_scripts', 'jquery_mumbo_jumbo');
any ideas to fix this?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to move the jQuery in the footer?’ is closed to new replies.