gpt4 book ai didi

jquery - html5boiler Plate + jquery mobile = 脚本加载两次

转载 作者:行者123 更新时间:2023-12-01 02:47:26 28 4
gpt4 key购买 nike

我正在使用html5 boilerplate开发一个基于jquery移动的实验性应用程序。作为 html 等的基础。

到目前为止我所做的基本上是:

  1. 下载并解压 html5 样板文件,然后在浏览器中查看它。确保脚本/样式正确加载。一切准备就绪,可以出发了。
  2. 添加 jquery mobile(cdn 托管完整版本 1.0 [今天发布?马上!])
  3. 添加$(document).ready(function () { console.log('ready'); });
  4. 重新加载。 'ready' 输出两次..稍有延迟后输出第二次..
  5. wtf bbq 以及 chrome 检查器中的此类检查情况。注意所有 javascript 文件似乎都加载了两次。
  6. 从头开始,在浏览器中提取 h5bp 加载,特别注意脚本加载一次。添加文档就绪处理程序,观察“ready”的一个输出。
  7. 添加 jquery mobile 观察脚本加载一次。
  8. 将所有脚本移至标记中。脚本加载一次。

有人知道发生了什么事吗?重现这个应该很容易,只需提取 h5bp 并将 jquery mobile 添加到底部的脚本部分,突然所有脚本都加载两次。将所有这些脚本移至 Modernizr 下方(或之前)的 head 标记中,这种情况将不再发生。

谢谢

最佳答案

Modernizr 使用 YepNope 加载脚本。如果您查看此处的问题:https://github.com/SlexAxton/yepnope.js/issues/10

您会看到脚本被有意加载两次:

Yepnope does request every file you put into it twice. The first time it loads itself into your cache as some sort of non-executable entity (an object element, or an img element, or a script element with a fake type attribute, depending on your browser). The second time it's injected, we inject it as an executable script, and this time it's cached. So there is really only the millisecond or less that it takes to execute the callback function and reinject a script tag extra (and however long it takes to access the cache).

http://yepnopejs.com 上也提到了这一点。主页。只需转到那里并向下滚动到我在我的开发工具中看到两个请求,为什么它会加载所有内容两次?

关于jquery - html5boiler Plate + jquery mobile = 脚本加载两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8189233/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com