theorise
theorise

Reputation: 7425

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?

Upvotes: 3

Views: 2078

Answers (2)

javascript is future
javascript is future

Reputation: 895

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

Upvotes: 0

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

Upvotes: 6

Related Questions