简体   繁体   English

有没有一个工具可以根据HTML和CSS中的用法自动生成代码来预加载图像?

[英]Is there a tool to automatically generate code to preload images based on usage in HTML and CSS?

I have a relatively large Javascript web application that contains a number of images, references from either HTML or CSS (but not dynamically from Javascript). 我有一个相对较大的Javascript Web应用程序,其中包含许多图像,来自HTML或CSS的引用(但不是从Javascript动态引用)。 Is there a tool that scans all my CSS and HTML files, collects the URL:s of all detected images and generates the code required to preload all of them so I can launch the application only when everything has been downloaded? 是否有一个工具可以扫描我的所有CSS和HTML文件,收集所有检测到的图像的URL并生成预加载所有图像所需的代码,这样我只有在下载了所有内容后才能启动应用程序?

Maybe you can launch your application in body's onload handler? 也许你可以在body的onload处理程序中启动你的应用程序? It should be fired when everything is fetched, and you'll then not need to iterate over all elements. 在获取所有内容时应该触发它,然后您不需要遍历所有元素。

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

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