如何缓存使用脚本标签下载的已下载 javascript 文件 [英] How to cache a downloaded javascript fle which is downloaded using script tag

查看:29
本文介绍了如何缓存使用脚本标签下载的已下载 javascript 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Web 应用程序,我需要在该应用程序加载时下载一个库.因此我使用脚本标签下载它现在我不希望每次加载应用程序时都下载它.我需要缓存这个.我知道我们可以使用 jquery、$.ajax(url:..., cache: true) 来实现.

I am developing a web application in which I need to download a library when the app is getting loaded. Hence I download it using the script tag Now I don;t want it to be downloaded each and every time when I load the app. I need this to be cached. I know that we can do it using jquery, $.ajax(url:..., cache: true).

但是有没有什么办法,不使用jquery就可以缓存.

But is there any way, whether we can cache it without using jquery.

推荐答案

您不能在纯 HTML 中强制执行缓存,但是,有 我们网站上有很多很好的解决方案,包括一个纯 JS 解决方案,它使用没有 jQuery 的纯 JavaScript.

You cannot enforce the cache in plain HTML, however, there are plenty of good solutions on our site, including a pure JS solution that uses plain JavaScript without jQuery.

这篇关于如何缓存使用脚本标签下载的已下载 javascript 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆