Preloading huge amount of images

我的未来我决定 提交于 2021-02-18 07:39:54

问题


I'm trying to do a parallel preload of images using the logic implemented on the below link.

http://blog.lieldulev.com/2010/05/21/parallel-image-preloading-in-js/

I have a huge amount of images, currently 350+ images with an average of 50KB file size each, amounting to a total of 20MB of images im trying to preload. I need the images for canvas drawing.

Using the above logic of parallel downloading, I'm having issues of the browser waiting for 2mins to finish loading the whole page. sometimes, it stops the script.

By the way, 20MB of images is currently the conservative amount of images. some set of images I need to preload my go to as much as 80MB!!

Is it even practical to preload such an amount of images? And if i need to preload, What is the best approach to my requirement? Should i do non-parallel? How about partial preload?

Thank you in advance Marv


回答1:


That is a perfect usecase for a MXHR (Multipart XHR) request. That means, a serverscript is reading your image files, decodes them as base64 string and streams those images to the browser. supplyJShelp is using this technique, but currently only for javascript & stylesheet files. Anyway, it's designed pretty modular, it should be no problem to extend it's functionality for any image type you need.

If you don't feel in the mood to do it yourself, don't worry - I'll update the script for image loading the next few days.



来源:https://stackoverflow.com/questions/4792568/preloading-huge-amount-of-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!