JQuery is not defined but jquery script is loaded in source

I'm new to Wordpress and I'm trying to use JQuery on a static home page. I'm getting the infamous "Uncaught ReferenceError: JQuery is not defined" error, although in the page source the JQuery script is loaded.

In my theme's functions.php :

function load_jquery() {        
  wp_deregister_script('jquery'); 
  wp_register_script('jquery',   'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', false, '2.1.3'); 
  wp_enqueue_script('jquery');
}
add_action('init', 'load_jquery');

In my home page template :

wp_enqueue_script('jquery'); 
wp_register_script( 'home-js',  get_template_directory_uri() . '/js/home-js.js' );
wp_enqueue_script( 'home-js',   get_template_directory_uri() . '/js/home-js.js' ); 
wp_register_style( 'my-style',  get_template_directory_uri() . '/my-style.css' );
wp_enqueue_style( 'my-style',   get_template_directory_uri() . '/my-style.css' ); 
wp_head(); 
</head>

My home.js is simply :

JQuery(document).ready(function () {
alert('hello world');
});

I had 1 plugin but I disabled it in case it was doing conflict. My home.js is loading properly (it is the file throwing the JQuery is not defined error. In the page source the JQuery script tag is linking properly to the Google file.

Answers 1

Related Questions