The progress event is fired periodically as the browser loads a resource.
| Bubbles | No |
|---|---|
| Cancelable | No |
| Interface | Event |
| Event handler property | onprogress |
Examples
Live example
HTML
<div class="example">
<button type="button">Load video</button>
<video controls width="250"></video>
<div class="event-log">
<label>Event log:</label>
<textarea readonly class="event-log-contents"></textarea>
</div>
</div>
CSS
.event-log-contents {
width: 18rem;
height: 5rem;
border: 1px solid black;
margin: .2rem;
padding: .2rem;
}
.example {
display: grid;
grid-template-areas:
"button log"
"video log";
}
button {
grid-area: button;
width: 10rem;
margin: .5rem 0;
}
video {
grid-area: video;
}
.event-log {
grid-area: log;
}
.event-log>label {
display: block;
}
JavaScript
const loadVideo = document.querySelector('button');
const video = document.querySelector('video');
const eventLog = document.querySelector('.event-log-contents');
let source = null;
function handleEvent(event) {
eventLog.textContent = eventLog.textContent + `${event.type}\n`;
}
video.addEventListener('loadstart', handleEvent);
video.addEventListener('progress', handleEvent);
video.addEventListener('canplay', handleEvent);
video.addEventListener('canplaythrough', handleEvent);
loadVideo.addEventListener('click', () => {
if (source) {
document.location.reload();
} else {
loadVideo.textContent = "Reset example";
source = document.createElement('source');
source.setAttribute('src', 'https://interactive-examples.mdn.mozilla.net/media/examples/flower.webm');
source.setAttribute('type', 'video/webm');
video.appendChild(source);
}
});
Result
Specifications
| Specification | Status |
|---|---|
| HTML Living Standard The definition of 'progress media event' in that specification. |
Living Standard |
| HTML5 The definition of 'progress media event' in that specification. |
Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
progress event | Chrome Full support Yes | Edge Full support ≤79 | Firefox Full support Yes | IE ? | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
