Skip to content
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

slow loading when scrolling on wheel (Chrome/Opera) #434

Closed
Youfka opened this issue Oct 11, 2017 · 29 comments
Closed

slow loading when scrolling on wheel (Chrome/Opera) #434

Youfka opened this issue Oct 11, 2017 · 29 comments

Comments

@Youfka
Copy link

Youfka commented Oct 11, 2017

When I scroll a page by mouse wheel, images loading with delay about 3sec. But when I drag scroll bar images loading instantly. This problem is in chrome and opera, in firefox is ok.

@aFarkas
Copy link
Owner

aFarkas commented Oct 11, 2017

I can not reproduce this. Can you please show a test case that proves this?

@Youfka
Copy link
Author

Youfka commented Oct 12, 2017

I sent you an email with example
btw on demo page https://afarkas.github.io/lazysizes/index.html
when I click to add new elements, it's loading with delay too, when I scroll with wheel

@aFarkas
Copy link
Owner

aFarkas commented Oct 12, 2017

There are two reasons for this related to some Chromium scroll improvements. 1. Chrome delays decoding images while doing smooth scroll. 2. Newer Chrome versions do throttle requestIdleCallback more while scroll.

You wouldn't experience such problems, if you wouldn't have changed the expand option in the first place.

lazysizes is the only lazy loader with a dynamic treatment of the expand option (which means the expand is only used if the network is in idle state). I really can't understand people setting it to 0.

@Youfka
Copy link
Author

Youfka commented Oct 12, 2017

I set expand to default, but images still loading differently when I scroll with wheel and drag scroll bar

@aFarkas
Copy link
Owner

aFarkas commented Oct 12, 2017

Can you try the following file instead of lazysizes:
https://gist.github.com/aFarkas/d4f1e48d90d9fb6a1aa07e43f43af438

@Youfka
Copy link
Author

Youfka commented Oct 12, 2017

feels like it's getting faster in Opera, but I don't see the difference in Chrome

@aFarkas
Copy link
Owner

aFarkas commented Oct 12, 2017

There is no fundamental difference between Opera and Chrome.

@Youfka
Copy link
Author

Youfka commented Oct 13, 2017

I think it's something with webkit browsers, demo page is still loading with delay in Opera and Chrome, but in Firefox is fast

@aFarkas
Copy link
Owner

aFarkas commented Oct 14, 2017

I haven't changed anything on the demo page. You can set the new ricTimeout to 50 and leave the expand as it is to fix your issue.

@judbd
Copy link

judbd commented Jan 30, 2018

Hi, I'm having the exact same problem : lazysize is very fast in firefox, but sometimes I have to wait for the script 2-3 seconds when I scroll with the wheel in chrome (no problem with scrollbar). Same with finger scrolling on chrome android.

@aFarkas
Copy link
Owner

aFarkas commented Feb 2, 2018

@judbd
Have you tried to lower the ricTimeout to 0-50? Does this change anything for you.

@judbd
Copy link

judbd commented Feb 4, 2018

I just tried

<script>
window.lazySizesConfig.ricTimeout = 50;
</script>

and

<script>
window.lazySizesConfig.ricTimeout = '50';
</script>

Don't know what is the good syntax. I put it just before loading the lazysize script as said in doc but it change nothing. Images load 2-3 sec after a mousewheel scroll, even if there were in browser cache, but all work as intended the second I click on the scrollbar (without even moving it). It's like the JS is temporized at mousewheel scroll only on chrome.

You can see an exemple here : https://judbd.com/portfolio (I let the lazyload active for a Day so you can see)

@aFarkas
Copy link
Owner

aFarkas commented Feb 4, 2018

@judbd
I'm on vacation and can only check with trackpad on my mac (which should be similar as wheel (technically the wheel "software path" is used with trackpad). I can not really reproduce your problem, but I can not see my suggested fix either (50 is the right way):

<script>
window.lazySizesConfig.ricTimeout = 50;
</script>

Can you re-check your configuration. (Or describe where I can find the customized configuration)?

Also: Is this a chrome win/chrome mac problem?

@judbd
Copy link

judbd commented Feb 4, 2018

Thank you @aFarkas , there is no rush. It's Chrome PC and Mac (a friend tells me it was the same on his mac). Sorry for the fix, It have a cache problem, I fixed it but now I have this error : Uncaught TypeError: Cannot set property 'ricTimeout' of undefined

The Image still load immediatly when I click on the scrollbar, but not with mousewheel.

@judbd
Copy link

judbd commented Feb 4, 2018

Ok I have fixed the init problem (sorry I'm not a developer :) ) The problem is still here. No problem with scrollbar but when mousewheel is used, there is some delay. I made a gif.

lazyload

as you can see, there is delay at scroll, but the instant I touch the scrollbar, the lazyload is unblocked and the image charged instantly (images are in cache, le lazyload not loading is the only thing that prevent the image display)

@franklinjavier
Copy link

franklinjavier commented Feb 22, 2018

@aFarkas I got this issues too. I made a mp4

My config

lazySizesConfig.ricTimeout = 50;
lazySizes.init();

@aFarkas
Copy link
Owner

aFarkas commented Feb 23, 2018

@franklinjavier
Can you please remove lazysizes and try the following script:
https://gist.github.com/aFarkas/f3ae9f7f9c40169851ebb0307d9c3e67

Another thing: To test it it might make sense to add a border and stlye it differently on .lazyloading, .lazyloaded this way you see at which time lazysizes does kick in without the additional network timing.

@franklinjavier
Copy link

franklinjavier commented Mar 1, 2018

@aFarkas sorry for the delay. It is hard to explain, but one of our script is causing this strange behaviour. If I not request this script, works as expected.
This technique of .lazyloading gave me this insight. Thanks

@aFarkas
Copy link
Owner

aFarkas commented Mar 3, 2018

@franklinjavier
This is a good information. Can you point me to what script it is, so I can know for other devs having this issue?

@davefmoore
Copy link

I'm experiencing the same issue that @franklinjavier posted in his video. The application this is used in is digital asset mgmt software which is notorious for showing a ton of images on the page... +2k in infinite scroll... which lazysizes or not, is bad for performance as we don't do virtual repeats or anything. I will follow the steps above and report back if this solves these issues.

@IanLunn
Copy link

IanLunn commented Mar 9, 2018

I am having this issue too. I believe it is due to external third-party scripts blocking rendering of any other JavaScript on the page whilst they load. It's not so much an issue with lazysizes but instead a case of better managing assets on the page and loading scripts via defer or async methods where possible.

@IanLunn
Copy link

IanLunn commented Mar 9, 2018

To add to what I said above, async or defering JavaScript might allow the DOM to load before the JavaScript does, but this doesn't solve the problem. As images are loaded as and when needed, you might find that external JavaScript is loading at the same time as trying to add the lazyloaded image to the DOM, and as such, there is a delay adding the image until the script has loaded.

@cshold
Copy link

cshold commented Mar 12, 2018

Same issue here. Have also narrowed it down to requestIdleCallback's scroll throttling in Chrome only, which causes lazysizes and other scripts from being completely blocked. Most in depth writeup of this I've found is in an issue in react-native-web.

In Nov 2016 there's a quote in this issue that says:

As long as lazysizes doesn't find any images to transform. It takes about 0.5-2ms to search for those elements throtteled by a combination of requestIdleCallback and setTimeout. (Maximum frequency 1 "search" per 125ms, but only if rIC is called.).

I tried stripping out the animations on our images and it does seem to lower the scroll throttle issue. @aFarkas are you able to shed light on your quote above?

@aFarkas
Copy link
Owner

aFarkas commented Mar 15, 2018

@cshold

This is a chrome bug. I just made some code changes to lazysizes to not really use rIC anymore. (I haven't yet released this version.) I will enable it as soon as this bug is fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=822269

@cshold
Copy link

cshold commented Mar 15, 2018

Are you able to share the version of it without rIC? Those Chrome bugs don't get addressed all that quickly I find. Happy to test it out.

@aFarkas
Copy link
Owner

aFarkas commented Mar 16, 2018

@cshold
I just released it.

@ciases
Copy link

ciases commented Apr 27, 2018

So, it there any solution to this problem? I've got this issue with lazysizes v.4.0.2 and Chrome 65

@wrainbird
Copy link

Am also still experiencing this issue after updating to 4.0.2 - with Chrome 66

@dexterbg
Copy link

Same issue with Chrome 67.0.3396.87 (Android) & v4.0.3, three seconds delay after scroll stop until images load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants