简体   繁体   中英

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

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?

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

在加载时,多个图像会减慢网页速度,但在执行时,我认为显示/隐藏图像最快

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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