Should I use Google's JSAPI in production code?

后端 未结 8 1636
傲寒
傲寒 2020-12-25 13:59

Possible duplicate of:

should-i-link-to-google-apis-cloud-for-js-libraries

also many other discussions, including:

Where do you incl

相关标签:
8条回答
  • 2020-12-25 14:36

    China has 500 million internet users and is not the only country that blocks google apis, this makes any website that uses http://www.google.com/jsapi dysfunctional. There is a small upside: due to the asynchronous load technique, these sites don´t display the same hang waiting to load as other sites that use the direct reference as eg:

    0 讨论(0)
  • 2020-12-25 14:37

    this file is after compression is 24KB, Addition of such file will increase HTTP requests and waiting for the response and execution and parse time that browser will take... if you say the file itself is cached everywhere, even if the file is cached in the browser, don't forget to consider the time it takes to read from disk, execute and parse...

    all of this for only getting the jQuery file or other common JS, I think referring directly to the requested resource is better

    check Google's best practices for more info.

    0 讨论(0)
  • 2020-12-25 14:43

    As others have pointed out answering similar questions, there's a downside. In some countries (such as Iran), these are apparently blocked, breaking the website.

    0 讨论(0)
  • 2020-12-25 14:46

    The benefit is it's hosted on googles super low latency and fast servers. you can also just use

    <script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script>
    

    its the same effect.

    0 讨论(0)
  • 2020-12-25 14:49

    Yes, definitely. Google encourages it. Everyone benefits. It's more likely to be in their cache, and it's one less file that you have to serve.

    0 讨论(0)
  • 2020-12-25 14:53

    keep in mind that google jsapi loads the scripts only after the document itself is loaded.

    So, if (for example) you are using jquery's $(document).ready() in your web app, you'll have to switch to google.setOnLoadCallback().

    0 讨论(0)
提交回复
热议问题