我在我的<script>标签中使用以下内容作为jQuery链接:
http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
Run Code Online (Sandbox Code Playgroud)
是否有"最新"版本的链接?像下面这样的东西(不起作用):
http://ajax.googleapis.com/ajax/libs/jquery/latest/jquery.js
Run Code Online (Sandbox Code Playgroud)
(显然不一定是将代码链接到可能更改的库但在开发中有用的好计划.)
有几种方法可以包含jQuery和jQuery UI,我想知道人们在使用什么?
我最近一直在使用Google JSAPI,但发现设置SSL连接需要很长时间,甚至只能解决google.com问题.我一直在谷歌使用以下内容:
<script src="https://www.google.com/jsapi"></script>
<script>
google.load('jquery', '1.3.1');
</script>
Run Code Online (Sandbox Code Playgroud)
我喜欢使用Google的想法,因此它在访问其他网站时被缓存并从我们的服务器节省带宽,但如果它一直是网站的缓慢部分,我可能会更改包含.
你用什么?你有什么问题吗?
编辑:刚刚访问过jQuery的网站,他们使用以下方法:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
编辑2:这是我去年包括jQuery没有任何问题的方式:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
不同的是删除http:.通过删除它,您不必担心在http和https之间切换.
假设我有一个相当庞大的JavaScript文件,打包到大约100kb左右.通过文件我的意思是它是一个外部文件,将在via中链接<script src="...">,而不是粘贴到HTML本身.
哪个是放在HTML中的最佳位置?
<html>
<head>
<!-- here? -->
<link rel="stylesheet" href="stylez.css" type="text/css" />
<!-- here? -->
</head>
<body>
<!-- here? -->
<p>All the page content ...</p>
<!-- or here? -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
每个选项之间是否存在功能差异?
实际上,您使用哪个CDN链接到您的jquery文件或任何javascript文件.一个人可能比另一个人更快吗?还有哪些其他因素可以起到决定使用哪种cdn的作用?我知道微软,雅虎和谷歌现在都有CDN.
对于某些人来说这可能是显而易见的,但我一直在想:我为什么要依靠Google的服务器为我的网站托管jQuery?
是不是因为它以这种方式加载得更快?
javascript ×4
jquery ×4
cdn ×2
performance ×2
google-api ×1
html ×1
httprequest ×1
optimization ×1
ssl ×1