Community Forums › Forums › Archived Forums › General Discussion › Move jQuery to Google CDN – Minimum Pro
Tagged: minimum pro jQuery
- This topic has 3 replies, 3 voices, and was last updated 9 years, 1 month ago by frobn.
-
AuthorPosts
-
July 31, 2015 at 6:22 am #161039Mark-CMember
Hi All,
Theme: Minimum Pro
jQuery: version 1.11.2I need to move jQuery to Google CDN
I have inserted the following code into my functions.php
// load jquery from google cdn in wordpress
function enqueue_jquery_google_cdn() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false, NULL, true );
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_jquery_google_cdn' );Problem
When i launch my page the backstretch image simply disappears.I see references in front-page.php to backstretch, but unsure how to configure.
Your help would be much appreciated.
http://localhostAugust 3, 2015 at 5:22 pm #161334Victor FontModeratorFirst, at the top of the page you say you need jQuery 1.11.2, which is the same version pre-loaded in WordPress. You are loading version 1.11.1, which is an earlier version.
Second, you need to make certain you are loading jQuery before any dependencies.
Third, why are you loading jQuery from Google? It's not going to provide you with any advantage over your local version and actually give you poorer performance scores because you won't have header expiration details because it's not coming from your server. That's why I download Google fonts whenever I can and deliver them from the local servers.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?August 3, 2015 at 11:58 pm #161363Mark-CMemberHi Victor,
Thank you for you reply.
My mistake, I meant to say V1.11.2 in the script.
I am simply code writing/testing in the local environment in readiness to roll out in live.The basic principle of a web page loading is the following logical order:
HTML
CSS
JAVAIn short, when CSS or Java is called upon you need to load them completely before you are able to render additional HTML. This waiting around will cause pagespeed issues that Google frown upon as well as poor user experience. Calling jQuery from Google built in libraries/servers will provide significant pagespeed advantages. However, we need to defer Java and CSS from loading on the page before HTML. Additionally, we need to be able to render all instances above the fold. Therefore, careful planning of site design and structure is key.
You mention that you load locally Google fonts from your server. Unless your servers out perform Google, have untold resources at there disposal around the world, fault tolerance incase of latency and so forth, you are simply making a call to a basic run of the mill server to deliver a font set to a users browser. Remember, based upon your sites cache configuration and a users previous web browsing experience, there is a high probability that certain objects have already been cached on the user machine. It makes no sense to simply make many calls for the same objects. Again, this is basic 101 on jQuery library scripts.
I understand that jQuery V1.11.2 must be present before any dependencies, i.e. resposonsive menu, backstretch, etc.
My original questiion is. how do I pull jQuery 1.11.2 from Google CDN?
Thank You
August 8, 2015 at 7:00 am #161783frobnMemberTry it this way in your function.
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js' );
wp_enqueue_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', array( 'jquery' ) , false, NULL, true );Are you moving jquery-migrate to the CDN also?
Suggestion: move your js to the bottom of your html. You can do it with a plugin or manually in the functions.php
Frank
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.