defer image loading on search/home (bug 898320)#364
Conversation
There was a problem hiding this comment.
why are you doing removeClass or doing classList.remove?
There was a problem hiding this comment.
Thanks, didn't know about classList.
|
@cvan polished the PR + added a demo screencast. it feels pretty good now. note: except that switching tabs and back breaks |
|
I feel like each thumbnail should be lazy-loaded, not the entire gallery section itself. afaict, we are doing lazy loading when you maximize the gallery as a modal (@potch and/or @spasovski worked on that iirc). also, it looks like we're deliberately waiting 2 seconds? are we aborting image requests if a request is requested, but it's not yet finished and we scroll past it and it's no longer needed? |
|
and the benefit of the lazy-loading here does not improve initial page load at all, correct? it's all just to reduce bandwidth, yes? |
|
also, thank you so much for this |
I think that can be done, I can add a check to make sure the image is within horizontal view as well as vertical.
The debounce rate is variable, I have it at 100ms for app icons and at least a second for screenshots. But if I lazy-load by thumbnail, I can reduce that rate. It was just to not queue up too many images as we scroll down
Thought crossed my mind, I'll give it a shot.
It sort of improves the initial page load as the UI may be laggy as it tries to load dozens of images at once. I checked the network tab, and even my laptop was taking a long time to load images on the viewport because so many were queued up.
np, thanks |
|
I dig this. |
|
Shiny stuff! One suggestion, maybe you could use a non-animating placeholder image instead of a throbber to reduce the amount of movement. Animation draws the eye and for this it's probably unecessary imho. |
|
@muffinresearch Updated to use non-animating placeholders...plus fade-ins as icing. |
That looks great! 😃 |
|
one last thing: can we do this for homepage / cat pages? |
|
Updated to work on all homepage/listing pages (exclude detail pages). |
|
Don't really like the way my solution looks on the homepage though: http://screencast.com/t/YhDZxPXAli4k Because switching between New + Popular tabs triggers a page rebuild, the images are reverted back to the placeholder images, then loaded in again. |
|
Homepage issue fixed: |
There was a problem hiding this comment.
maybe do it on z.page or z.body
There was a problem hiding this comment.
seems scroll only triggers on doc for me
|
r? i'm sure there are some wrong doings in the code perf-wise. the CSS transitions of multiple images at once are pretty laggy too. |
|
I investigated doing deferring image loading horizontally for the screenshots (checking if the image is visible within the main container), but it introduces really specific code. And it'd be ugly code since we don't have JQuery.offset in Commonplace. |
|
@spasovski r? |
|
r+ I like this. I do have a minor concern about this and other of our lazy-loading performance work about what happens when we go back to a page using the back button, only because we've seen a lot of odd (and sometimes hard to reproduce consistently) errors with missing content in those cases. But I don't have a smoking gun pointing to our lazy-loading, just that I suspect it might be tickling some platform bugs that others aren't seeing. I'm happy to have this in, and will keep an eye out for missing content issues. |
There was a problem hiding this comment.
I'd like to make sure that we're not reinventing the wheel here before landing this.
There was a problem hiding this comment.
This module allows us to throttle icons but debounce screenshots.
There was a problem hiding this comment.
I always get confused by the two; can you explain?
There was a problem hiding this comment.
As the user scrolls down the page, they will still be able to see the icons since their scroll events are throttled (events are run no matter what in sure intervals).
Screenshots won't be shown until the user stops scrolling because screenshots are debounced (events are grouped and run once). Because we don't want screenshots loading as the user flies down.
There was a problem hiding this comment.
awesome - good explanation, thanks
Demo: http://screencast.com/t/Cxr8Dbp3s1A