Is it faster to swap an img src or show/hide multiple images?

限于喜欢 提交于 2020-01-04 03:53:48

问题


What is the best practice to use when swapping an image on a webpage? Altering the image source or just showing/hiding multiple images on the page?


回答1:


you have to choose in order to balance speed, with your two options:

Altering the image source

this way, the page will load faster because it only gets the visible images but it will take a little longer to show the new image when you change src attribute

just showing/hiding multiple images

this way, you are loading all the images on page load which will make it slower on loading and faster on swapping the images




回答2:


At the load time, multiple images will slow down the webpage, but at the execution time, I think it will be fastest to show/hide the images



来源:https://stackoverflow.com/questions/11938062/is-it-faster-to-swap-an-img-src-or-show-hide-multiple-images

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