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

前端 未结 7 2133
甜味超标
甜味超标 2020-12-04 17:07

Google hosts some popular JavaScript libraries at: http://code.google.com/apis/ajaxlibs/

According to google:

The most powerful way to load th

7条回答
  •  无人及你
    2020-12-04 17:14

    If you were to write a boatload of JavaScript that only used the library when a particular event happens, you could wait until the event happens to download the library, which avoids unnecessary HTTP requests for those who don't actually end up triggering the event. However, in the case of libraries like Prototype + Scriptaculous, which downloads over 300kb of JavaScript code, this isn't practical.

提交回复
热议问题