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. Because theme's static js files is calling via array( 'jquery' )
attributes.
I just want to move jquery only from header to footer.
NOTE: I have tried other suggestions on Stackexchange but none of them didn't work on my blog. (Such us: Enqueue core jQuery in the footer?)
How can I do it?