{"id":1036,"date":"2012-07-12T10:42:40","date_gmt":"2012-07-12T10:42:40","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=1036"},"modified":"2012-07-12T10:42:40","modified_gmt":"2012-07-12T10:42:40","slug":"call-include-load-latest-jquery-version-in-wordpress-theme-plugin","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/call-include-load-latest-jquery-version-in-wordpress-theme-plugin\/","title":{"rendered":"Call \/ Include \/ Load Latest jQuery Version in WordPress Theme \/ Plugin"},"content":{"rendered":"<p>If you are wondering how to\u00a0<strong>Call \/ Include \/ Load Latest jQuery Version in WordPress Theme \/ Plugin<\/strong>, then look no further! In this article, I am going to share a very simple way that use can use to always load the latest jQuery version either in your Theme or Plugin or both. Read on to find out more.<!--more--><\/p>\n<h2>How to Call \/ Include \/ Load Latest jQuery Version in WordPress Theme \/ Plugin<\/h2>\n<p>One of the strongest reason to include latest jQuery version is to take advantage of new features that jQuery offers without having to manually change the link pointer to latest jQuery version. That said, following are the ways to load latest jQuery version in WordPress:<\/p>\n<h3>Load Latest jQuery Version in WordPress Theme:<\/h3>\n<p>Paste the following code in your theme&#8217;s function.php file:<\/p>\n<pre class=\"lang:php decode:true\">function ewd_load_js()\n{\nif ( !is_admin() )\n{\nwp_deregister_script( 'jquery' );\n\nwp_register_script('jquery', 'http:\/\/code.jquery.com\/jquery-latest.min.js');\n\nwp_enqueue_script('jquery');\n}\n}\n\nadd_action('wp_enqueue_scripts', 'ewd_load_js');<\/pre>\n<h3>Load Latest jQuery Version in WordPress Plugin<\/h3>\n<p>Or if you need the latest jQuery version to be loaded in your custom plugin, then simply paste the following code in your plugin&#8217;s main file:<\/p>\n<pre class=\"lang:php decode:true\">function ewd_load_js_plugin()\n{\nwp_deregister_script( 'jquery' );\n\nwp_register_script('jquery', 'http:\/\/code.jquery.com\/jquery-latest.min.js');\n\nwp_enqueue_script('jquery');\n\n}\n\nadd_action('wp_enqueue_scripts', 'ewd_load_js_plugin');<\/pre>\n<h3>Load JavaScript(s) in Footer<\/h3>\n<pre class=\"lang:xhtml decode:true crayon-selected\">function ewd_load_js_plugin()\n{\nwp_deregister_script( 'jquery' );\n\nwp_register_script('jquery', 'http:\/\/code.jquery.com\/jquery-latest.min.js', 'false', 'false', true);\n\nwp_enqueue_script('jquery');\n\n}\n\nadd_action('wp_enqueue_scripts', 'ewd_load_js_plugin');<\/pre>\n<p>So what is different in the above code? Well, if you pay close attention, we now have some new arguments appended in the wp_register_scripts function. Especially the argument &#8220;true&#8221;. \u00a0This corresponds to the $in_footer variable and it is this value that is responsible loading the scripts in footer. Here would be the actual usage of wp_register_script:<\/p>\n<pre class=\"lang:php decode:true \">&lt;?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?&gt;<\/pre>\n<p>$handle &#8211; Name of the script<\/p>\n<p>$src &#8211; URL to script<\/p>\n<p>$deps &#8211; Array of handles of\u00a0all the registered scripts that this script depends on, that is the scripts that must be loaded before this script.<\/p>\n<p>$ver &#8211;\u00a0String specifying the script version number, if it has one, which is concatenated to the end of the path as a query string.<\/p>\n<p>$in_footer &#8211;\u00a0Normally scripts are placed in the &lt;head&gt; section. If this parameter is true the script is placed at the bottom of the &lt;body&gt;. This requires the theme to have the wp_footer() hook in the appropriate place.<\/p>\n<h5>Your turn!<\/h5>\n<p>Do you know of any other ways to <em><strong>Call \/ Include \/ Load Latest jQuery Version in WordPress Theme \/ Plugin<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are wondering how to\u00a0Call \/ Include \/ Load Latest jQuery Version in WordPress Theme \/ Plugin, then look no further! In this article, I am going to share a very simple way that use can use to always load the latest jQuery version either in your Theme or Plugin or both. Read on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,13,8,11],"tags":[100,31,30],"class_list":["post-1036","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippets","category-tips-and-tricks","category-wordpress","category-wordpress-tips-and-tricks","tag-latest-jquery-google-cdn","tag-wordpress-snippets","tag-wordpress-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-gI","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=1036"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/1036\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=1036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=1036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=1036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}