Topics:

Recent Posts:

Archive

❮ Go Back

How to track the loading progress of an image in JavaScript

Is it possible to monitor the loading progress of an image in JavaScript while it’s being downloaded? I’d like to use the HTML5 <progress> element to visually display the loading status of an image.


Ideally, I’m looking for something like this:


var img = new Image();
img.onloadprogress = function(e) {
progressBar.value = e.loaded / e.total;
};
img.src = "image.jpg";

Is there any way to achieve this or a similar effect?




Showing comments related to this review.

Online Tools

Member's Sites: