-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cancel_on_exit
for video
elements
#626
Comments
Sorry, this it's not technically possible at the browser level. Cancelation works only for images. |
Is that true? I'm currently looking at MDN to workaround this and it seems like calling
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/load#usage_notes ...I can't seem to find more info on this, only in MDN, maybe I'm missing something 🙈 |
Wow, thank you for your finding, we should definitely try that. Do you have time to verify that information? If that works, it should definitely be the case for an update of vanilla-lazyload! |
I'll play around this week and will report back! |
Alright, I've cooked up a sample here: https://jsbin.com/zayemoticu/1/edit?js,output:
|
Hello, If you have time, I would do something much simpler:
What do you think? |
Sounds good, I'll try it out this week (maybe today if I have the time)! Regarding the JSBin, try scrolling by clicking on the scroll-bar with the mouse rather than using the scroll-wheel, I noticed that this triggers unloads more reliably, at least on FF & Brave: 2025-01-21_13_30_02_brave.mp4
After implementing this, I had a similar idea with the button, not sure why I went this route lol... |
Seems that it behaves differently if the action is performed via button (no canceled message, the download just stops). |
Is your support request related to a problem? Please describe.
I have a single page site (large HTML file with lots of content) which contains a lot of
video
elements that range from1mb-10mb
in size. When the user scrolls quickly past the page to the very bottom, the largervideo
take a while to load and are not canceled. Due to this, when the internet connection quality is not very good, the page lags.To Reproduce
lazyload
.LazyLoad
and pass incancel_on_exit: true
option.Expected behavior
The video elements get canceled and stop loading if the user scrolls past them during load.
LazyLoad version
19.1
Desktop (please complete the following information):
Additional context
It seems that cancelling only works for
img
elements per:https://github.com/verlok/vanilla-lazyload/blob/master/src/cancelOnExit.js#L12
Is there some reason why its only enabled on
img
tags? Is there some workaround I could use to enable canceling forvideo
elements?The text was updated successfully, but these errors were encountered: