放心使用 Google Libraries API
2011-02-15 23:00
323 查看
Google 在2008年发布了 Google Libraries API。Google 将优秀的 JavaScript 框架部署在其 CDN 上,在我们的网站上使用 Google Libraries API 可以加速 JavaScript 框架的加载速度。
可是由于 Google 有时会被不稳定,所以一直也不敢使用 Google Libraries API。今天在 jQuery.com 的源代码中看到了非常棒的使用方法,可以避免 Google Libraries API 没有正确加载时造成的影响。
判断 window.jQuery 对象是否存在,不存在则使用由网站自己提供的 jQuery。
可是由于 Google 有时会被不稳定,所以一直也不敢使用 Google Libraries API。今天在 jQuery.com 的源代码中看到了非常棒的使用方法,可以避免 Google Libraries API 没有正确加载时造成的影响。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script>!window.jQuery && document.write('<script src="http://code.jquery.com/jquery-1.4.2.min.js"><\/script>');</script>
判断 window.jQuery 对象是否存在,不存在则使用由网站自己提供的 jQuery。
相关文章推荐
- Google AJAX Libraries API基础与使用指南
- 使用google的translation api 为网站添加翻译功能
- 如何在Google Maps API中使用谷歌地图的数据
- 掌握 Ajax,第 9 部分: 使用 Google Ajax Search API
- Google Map API使用详解(八)——Google Map坐标系统总结(上)
- google map api 与jquery结合使用(1)--控件,监听器[转帖]
- Google Map API使用中出现的“google未定义”解决办法
- Android Google Map API使用的八个步骤
- android google map api的具体使用
- Google Map API使用详解(七)——加载Google Map API URL的详细解读
- Google Map API使用详解(二十)——实现Google Map本地搜索框(下)
- 使用 Google API 进行翻译的 Python 小工具
- 掌握 Ajax,第 9 部分: 使用 Google Ajax Search API
- 使用google的ajax API中的翻译小工具
- 获得Google Map API Key(android map中使用)
- 使用Google Maps Javascript API实现反向地址解析
- 在Google Map API中使用控件
- Google Map API的使用
- 使用Google Weather API查询天气预报