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

查看:94
本文介绍了如何在另一个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天全站免登陆