简体   繁体   English

如何在外部脚本中加载Google的jQuery?

[英]How to Load Google's jQuery in External Script?

Stupid question, but does anyone know how to load google's jquery from an external script so it doesnt clunk up my header? 愚蠢的问题,但是没有人知道如何从外部脚本加载google的jquery,这样它就不会使我的标头显得笨拙吗? In other words, I want to take the code below (probably starting at the google.load stuff and save it inside another file to include in my header. I want to keep my view source pretty :) 换句话说,我想使用下面的代码(可能从google.load开始,然后将其保存在另一个文件中,以包含在我的标头中。我想保持我的视图源很漂亮:)

<script src="http://www.google.com/jsapi?key=MySeCretKeyHere" type="text/javascript"></script>
<script type="text/javascript">google.load("jquery", "1.4.0");google.load("jqueryui", "1.7.2");
    google.setOnLoadCallback(function(){ $(document).ready(function(){ 
//onload stuff goes here
});});
</script>

Just as you say: 就像你说的那样:

load.js: load.js:

google.load("jquery", "1.4.0");google.load("jqueryui", "1.7.2");
    google.setOnLoadCallback(function(){ $(document).ready(function(){ 
//onload stuff goes here
});});

html: 的HTML:

<script src="http://www.google.com/jsapi?key=MySeCretKeyHere" type="text/javascript"></script>
<script src="load.js" type="text/javascript"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM