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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
you have to choose in order to balance speed, with your two options:
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
this way, you are loading all the images on page load which will make it slower on loading and faster on swapping the images