Move Jquery.js to Footer

I want to move jquery.js from header to footer. I have tried following code:

//Remove jQuery Default
function replace_jquery() {
if (!is_admin()) {
wp_deregister_script(‘jquery’);
}
}
add_action(‘init’, ‘replace_jquery’);

//Load on Footer
add_action(‘wp_footer’, ‘jquery_code’);
function jquery_code(){
?>
<script type=’text/javascript’ src=’https://example.com/wp-includes/js/jquery/jquery.js’></script>
<?php
};

The issue is that If I run first piece of above code, js files of my theme are removed with jquery.js.

I just want to move jquery only from header to footer.

NOTE: I have tried other suggestions on Stackexchange but none of them aren’t working on my blog. (Such us: Enqueue core jQuery in the footer?)

How can I do it?

Read more here:: Move Jquery.js to Footer

Leave a Reply

Your email address will not be published. Required fields are marked *