Skip to content Skip to sidebar Skip to footer

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?

Solution 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

Solution 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

Post a Comment for "Is It Faster To Swap An Img Src Or Show/hide Multiple Images?"