不要这么干,因为jquery会更新的,最好你直接用google提供的jquery链接,每次都是给你最新版(这样你就不用担心服务器带宽和以后更新问题了)
你这种想法可以实现。
在你的js中写个功能,执行js时,首先将jquery加载到页面上(创建script标签),再执行在自己的js;
但是终归这样实现和页面引入没什么区别。
反正一个jquery文件 (一般用的是mini版) 代码没几行
直接把该文件的代码复制到你的js文件中就可以了
有时我也这么用 ~
(function() {
var jsfiles = new Array(
"script/jquery.js",
"script/aaa.js"
);
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
if(docWrite) {
var allScriptTags = new Array(jsfiles.length);
}
var host = "lib/"; //文件的所在目录
for (var i=0, len=jsfiles.length; i
allScriptTags[i] = "";
} else {
var s = document.createElement("script");
s.src = host + jsfiles[i];
var h = document.getElementsByTagName("head").length ?
document.getElementsByTagName("head")[0] :
document.body;
h.appendChild(s);
}
}
if (docWrite) {
document.write(allScriptTags.join(""));
}
})();
试试吧~这个是通过 js引用 JS的方法,需要引用的JS放到数组里就行了 jsfiles
为什么要怎么做呢?不是可以直接引入jquery吗?