简体   繁体   中英

Is is possible to synchronously check whether a script exists in the browser's cache from JS?

Let's say I have a script (A) that wants to load another script (B), but only if B is already available in the browser's cache. (For example, maybe A would load a different script (C) if B wasn't there.) Is it possible to know that?

I think that the better way to solve your problem is to save information about all uploaded scripts in localStorage. Then on next page load check each scripts status and if scripts status is cached try to load it from cache.

That's it!

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