function uw_load_scripts() {
// De-register the built in jQuery
wp_deregister_script('jquery');
// Register the CDN version
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js', array(),'','1.1', true);
// Load it in your theme
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'uw_load_scripts' );
I have this nice function in mytheme/function.php. They say this should move the js to the footer, but in my case it doesn’t. Any idea on why or/and how to move it to footer?
HOW IT WORKS
Here in your code
$in_footer
parameter ofwp_register_script()
is set totrue
.You can enqueue in the footer by setting the
$in_footer
parameter totrue
in your call towp_enqueue_script()
orwp_register_script()
Reference>>
WHY YOU CANT
Your link towards jquery seems to be invalid. Use correct link.
You can use this one instead;
AND
Change version accordingly or set
false
,Where version is,
String specifying the script version number, if it has one, which
is concatenated to the end of the path as a query string. If no version is
specified or set to false, then WordPress automatically adds a version number
equal to the current version of WordPress you are running. If set to null no
version is added. This parameter is used to ensure that the correct version
is sent to the client regardless of caching, and so should be included if a
You can move it down by using true in your enque function but if the script you are enqueueing has anything defined as a dependency in WordPressâ wp_default_scripts() function, it will ignore your request to put it in the footer.
See Here
Getting all JavaScript into the Footer in WordPress
There is an typo “1.1.10” should be “1.10.1” otherwise you get an 404 Error.
**Try below code
from function.php or comment it.
Now add your js to your theme/footer.php**
Code :