简体   繁体   English

如何预加载JS文件?

[英]How to pre-load JS files?

So I have a website, that has a configurator, where you can configure your own product.所以我有一个网站,它有一个配置器,你可以在那里配置你自己的产品。 The configurator website needs additional .js files, like dist.js and libs.js .配置器网站需要额外的.js文件,如dist.jslibs.js Both of those files are around 2mb's each.这两个文件每个都大约 2mb。

My question is: how can I start downloading those files on the landing page, so that when user goes to /configuration.html , he already started downloading those files?我的问题是:如何开始在登录页面上下载这些文件,以便当用户转到/configuration.html ,他已经开始下载这些文件?

你需要在你的 HTML 中定义文件: <script src="yourfilename.js"></script>一定要把 .js 放在最后,否则它不会工作。

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

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