Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Elwin de Witte
Elwin de Witte
1,357 Points

Multi-stage image loading

Hi everyone,

I'm working on a website and I would like to have images enhance in quality when loading. For instance; 1st one: 720p 2nd: 1080p 3rd: 2160p. How do I do this?

Thanks for your help!

1 Answer

Try this one and tell why it's not the way you need. https://api.jquery.com/load-event/

«For example, consider a page with a simple image:

<img src="book.png" alt="Book" id="book">

The event handler can be bound to the image:

$( "#book" ).load(function() {
  // Handler for .load() called.
});

As soon as the image has been loaded, the handler is called».