简体   繁体   English

使用“ yepnope” JavaScript脚本加载器强制刷新脚本

[英]Force a script refresh using the “yepnope” JavaScript script loader

Using yepnope.js . 使用yepnope.js I need to "refresh" the script, but yepnope prevents files with the same url from being re-loaded. 我需要“刷新”脚本,但是yepnope可以防止重新加载具有相同url的文件。

In the documentation, they suggest using a plugin to allow files to refresh. 他们在文档中建议使用插件来刷新文件。 Is there such a plugin available? 有没有这样的插件可用? What are my other options for refreshing a script during runtime in Javascript? 在运行时使用Javascript刷新脚本时,我还有哪些其他选择?

I tried appending a random number as a query argument to the url. 我尝试将一个随机数作为查询参数附加到url。 That worked, but made it much more difficult to set breakpoints while debugging, so I'd rather not do this. 那行得通,但是在调试时设置断点变得更加困难,所以我宁愿不这样做。

Any suggestions? 有什么建议么? Thanks! 谢谢!

IMHO it is not possible do that using any yepnope method. 恕我直言, 不可能使用任何yepnope方法进行该操作。

I think you only has two possibilities: 我认为您只有两种可能性:

  • Adding a random parameter to the querystring (your current solution) 向查询字符串添加随机参数(您当前的解决方案)
  • Changing the yepnope script to: 将yepnope脚本更改为:
    1. expose the scriptCache yepnope var 公开scriptCache yepnope var
    2. reset the scriptCache[url] 重置scriptCache[url]
    3. and finally remove the created DOM img node that has your url as src . 最后删除创建的url为src的 DOM img节点
    4. In addition set the cache headers to expired, to prevent browser cache. 另外,将缓存头设置为过期,以防止浏览器缓存。

good luck 祝好运

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

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