简体   繁体   中英

Force a script refresh using the “yepnope” JavaScript script loader

Using yepnope.js . I need to "refresh" the script, but yepnope prevents files with the same url from being re-loaded.

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?

I tried appending a random number as a query argument to the 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.

I think you only has two possibilities:

  • Adding a random parameter to the querystring (your current solution)
  • Changing the yepnope script to:
    1. expose the scriptCache yepnope var
    2. reset the scriptCache[url]
    3. and finally remove the created DOM img node that has your url as src .
    4. In addition set the cache headers to expired, to prevent browser cache.

good luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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