I have added a WordPress function to load jQuery Library from Google Hosted Libraries
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
}
it create the something like this
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
how can I include it with fallback option, as per html5boilerplate suggested
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"></script>')</script>
like this
Try this.
Replace your code with this code. This will handle all.
Put this code in functions.php
Answer
of @Mangesh Parte can be short like,You can try this:
Why many answers with server-side solution ? Think about who lives in China and Google has been blocked.
Here is the correct answer (no server-side) :
For WordPress 4.5.0 + :
wp_add_inline_script()
#Note : Change the version and your own local jQuery source.