An extensive explanation of the code can be found [here](https://blog.atlantishq.de/post/lazyload/).