How to show a preloader for jpgs?

I saw this website and others doing a similar function.

I like how they use a preloader for each small thumbnail and I was wondering how they did it. I would like to try it myself, but not sure which direction to go in.

Any help would be great!!