Preloading lots of images?

edited March 2016 in p5.js

Hey guys, I'm new to P5 but can't think of how to solve this issue. Basically, on page load, I want to preload a whole image folder so that lots of images can be used as css background-images without any loading occuring during the rest of the site visit.

Unfortunately, i'm working with over 100 images all of which are fairly high quality. When I switch between background-images, I get the slight flicker whilst it loads the next bg-image. Any advice on how to solve this issue?



  • Instead of trying to load them all up-front (which is a really bad idea) you should instead be loading them individually either when required or in the background in readiness for when they are required; and test that an image is loaded before displaying it... pseudocode:

    • preload(image 1)
    • display image 1
    • preload image 2 into a hidden div
    • test image 2 is loaded
    • display image 2
    • etc.
Sign In or Register to comment.