如何在另一个 javascript 文件中包含 jquery [英] how to include jquery in another javascript file

查看:32
本文介绍了如何在另一个 javascript 文件中包含 jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 javascript 文件,我想在这个 js 文件中包含 jquery.你有什么建议吗?

I have a javascript file and I want to include jquery in this js file. Do you have a suggestion?

推荐答案

在包含您自己的 JavaScript 之前,只需包含 jQuery 的 JavaScript:

Simply include the JavaScript for jQuery before you include your own JavaScript:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="path/to/your/script.js"></script>

虽然其他人建议简单地将 jQuery 复制并粘贴到您自己的 JavaScript 文件中,但最好将 jQuery 与规范源分开包含,因为这将允许您利用浏览器和中间服务器为此所做的缓存文件.

Though others have suggested simply copying and pasting jQuery into your own JavaScript file, it's really better to include jQuery separately from a canonical source as that will allow you to take advantage of the caching that your browser and intermediate servers have done for that file.

这篇关于如何在另一个 javascript 文件中包含 jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆