Search code examples
javascriptyepnopedynamic-script-loading

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!


Solution

  • 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