What are advantages of using google.load('jQuery', ...) vs direct inclusion of hosted script URL?

Active3 hr before
Viewed126 times

9 Answers


What are the real advantages of using ,The most powerful way to load the libraries is by using google.load() ...,It lets Google change the URL (but they can't since the URL method is already established), Profile image changes (Gravatar images won’t be recoverable after email change)


What are the real advantages of using ,Google hosts some popular JavaScript libraries at: http://code.google.com/apis/ajaxlibs/,Edit: Yep, at very least when using the direct script tags to the location, the javascript library will be cached if someone has already called for the library from google (e.g. if it were included by another site somewhere).,Because it lets you switch directly to a new version of the library in the javascript, without forcing you to rebuild/change templates all across your site.

What are the real advantages of using

google.load("jquery", "1.2.6")

google.load("jquery", "1.2.6")
load more v

And the code using Google’s CDN looks like this:,To select that element using jQuery looks like this:,Using the jQuery CDN, you’d use this code:,Add the code listed in bold on line 5 below to the script:

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.min.js">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/
load more v

HTML, CSS, and JavaScript are the three fundamental languages of the web. We structure our websites with HTML, style them with CSS, and add interactive functionality with JavaScript. In fact, most animations and any action that happens as a result of a user clicking, hovering, or scrolling are constructed with JavaScript.,By comparing a simple “Hello, World!” program in both JavaScript and jQuery, we can see the difference of how they’re both written.,Delete the current <button>and <p> tags from within the body of your index.html file, and add the following to your HTML document:,In our style.css file, we will use a minimal amount of CSS to hide the overlay with display: none and center it on the screen.

document.getElementById("demo").innerHTML = "Hello, World!";
load more v

Loading the bvapi.js API asynchronously,If you do not use jQuery, include the following JavaScript:,Use the attributes parameter to measure values such as:,Refer to the attributes parameter for more detailed information.

<script type="text/javascript">
    var bvapiUrl = window.location.protocol + "//default.ugc.bazaarvoice.com/bvstaging/static/1235-en_us/bvapi.js";
    window.loadBazaarvoiceApi = function(callback) {
        if (window.$BV) {
        } else {
                url: bvapiUrl,
                cache: true,
                dataType: "script",
                success: function() {
load more v

This time, the browser will not interpret the <script> tag as a JavaScript context, and instead simply displays the original string in the page.,Instead, simplify the data passing from Mako to JavaScript as follows.,The way to properly JavaScript-escape code in Mako is shown in the following example.,This step represents the loading and executing of JavaScript from the HTML page by the JavaScript engine. This step should be safe, if data was properly JavaScript-escaped earlier.

load more v

You can also load at.js asynchronously using this code:, You can also load at.js asynchronously using this code: var script = document.createElement('script'); script.async = true; script.src = "<URL to at.js>"; document.head.appendChild(script); ,To load at.js asynchronously:,Script profile attributes

You can also load at.js asynchronously by adding the async attribute to the script tag that loads at.js. Use something like this:

<script src="<URL to at.js>" async></script>
load more v

Add a script into select pages using plugins such as Headers and Footers,The easiest way to add a Javascript file to WordPress is using the Insert Headers and Footers plugin. ,Add a Javascript file to your theme header,If you would like to simply use a plugin for embedding a javascript reference to the WordPress theme’s header or footer file, ‘Insert Headers and Footers’ plugin is an easy option.

Use the location that matches best your specific needs using the following as an example. Note that <theme-you-are-using> needs to be changed to the name of the directory of the theme you are using, e.g. twentytwenty

<script src="https://www.website.com/wp-content/themes/<theme-you-are-using>/js/file.js"></script>
load more v

One way this could manifest itself is with img elements and the load event. The event could fire as soon as the element has been parsed, especially if the image has already been cached (which is common).,Otherwise, if field satisfies its constraints, then move on to the next element.,If the event is canceled, then set the current target element to the immediate user selection.,Set the current target element to the immediate user selection.

For example, suppose a page looked at its URL's query string to determine what to display, and the site then redirected the user to that page to display a message, as in:

   <li><a href="message.cgi?say=Hello">Say Hello</a>
   <li><a href="message.cgi?say=Welcome">Say Welcome</a>
   <li><a href="message.cgi?say=Kittens">Say Kittens</a>

If the message was just displayed to the user without escaping, a hostile attacker could then craft a URL that contained a script element:

https: //example.com/message.cgi?say=%3Cscript%3Ealert%28%27Oh%20no%21%27%29%3C/script%3E
load more v

Other "using-undefined" queries related to "What are advantages of using google.load('jQuery', ...) vs direct inclusion of hosted script URL?"