引用 DOJO Javascript 文件
我是道场新手。我有一个关于 dojo 框架的问题。
在这两种情况下引用 DOJO js 文件有什么区别
第一种情况:
<script src="dojo.js"
djConfig="parseOnLoad: true">
</script>
第二种情况:
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
非常感谢。
I am new to DOJO. I have one question regarding the dojo framework .
Is there any difference in referring to the DOJO js file in either cases
First case:
<script src="dojo.js"
djConfig="parseOnLoad: true">
</script>
Second case:
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/dojo.xd.js"
djConfig="parseOnLoad: true">
</script>
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一种情况从相对于 Web 服务器文档根的路径调用
dojo.js
JavaScript 文件(核心 Dojo 库)。换句话说,它是 Dojo 库的本地安装(服务器本地)。第二个从外部源调用核心 Dojo 库文件,在本例中是 Google API 库。它包含
.xd
作为其文件名的一部分,以指示 Dojo 工具包的此特定版本 支持跨域加载在本地安装 Dojo 工具包库的一个好处是,您可以自定义构建以仅包含您需要的组件,这可能会导致更精简的 JavaScript 集文件供您的用户下载。
使用 Google API 等第三方的好处是它们很常用,因此许多用户可能已经在浏览器缓存中拥有核心文件,从而在访问 Web 应用程序时根本不需要下载它们。不过,总体文件下载大小可能会大于您自己组装的自定义版本。像 Google API 这样的服务提供了多个不同版本的 Dojo 工具包可供使用(上面的版本使用的是 1.6),以防您的应用程序有特定的版本需求。相反,如果您对应用程序有不同的需求,则需要自己维护多个版本的本地安装。
The first case calls the
dojo.js
JavaScript file (core Dojo library) from a path relative to the web server's document root. In other words, it is a local installation (local to the server) of the Dojo libraries.The second calls the core Dojo library file from an external source, in this case the Google APIs library. It includes the
.xd
as part of its filename to indicate that this particular build of the Dojo toolkit supports cross-domain loadingA benefit of installing the Dojo toolkit libraries locally is that you can customize your build to include only the components you need, possibly resulting in a much leaner set of JavaScript files for your users to download.
A benefit of using a 3rd party like Google APIs is that they are commonly used and therefore many users may already have the core files in their browser caches, eliminating the need to download them at all when accessing your web application. The overall file download size is likely to be larger than a custom build you put together yourself though. A service like Google APIs makes several different versions of the Dojo toolkit available for use (the one above is using 1.6), in case you have specific version needs for your application. In contrast, you would need to maintain local installations of multiple versions yourself if you had differing needs for your applications.