splide icon indicating copy to clipboard operation
splide copied to clipboard

Console log out JavaScript violation warning messages at the start & when autoplay in use.

Open dragonitaq opened this issue 5 years ago • 3 comments

I have setup splide with autoplay: true, interval: 3000, for image carousel in one container

I also setup another splide with video extension for another video carousel in another container but without autoplay enable.

At the start of the app, a warning message immediately log into console:

[Violation] Added non-passive event listener to a scroll-blocking event. Consider marking event handler as 'passive' to make the page more responsive.

Then every 3 seconds, a new warning message log into console:

[Violation] Forced reflow while executing JavaScript took 247ms

I'm not sure if this is something we should be concerning. But my gut feeling tells we should. Even with these warning message, splide works as expected.

Please refer to screenshot below:

Screenshot 2021-02-03 222517

dragonitaq avatar Feb 03 '21 14:02 dragonitaq

These warning messages look to me like issues that would be picked up by Google Lighthouse to help optimize your page in terms of performance and best practices

The two errors here look to me to be completely separate issues. The first one, non-passive event listener, is a known Splide issue. Last I read, the author(s) don't plan on fixing it. Splide uses an event listener to prevent scrolling while you are navigating a slider with the "drag" feature. Basically, if you're on mobile, you won't accidentally start vertically scrolling while swiping left and right (or up and down if you use vertical Splide) on your Splide gallery. If you don't care for the ability to navigate through a Splide element by touch-swiping, you can simply add "drag: false," to your Splide initialization and this warning will go away. However, it isn't very likely that this will affect performance or usability of your page, so if you don't care about your Google Lighthouse score, ignore it.

The second issue looks like something that would affect your performance. It isn't something I can claim I'm familiar with, though, so I'm just going to leave you this article that will explain better than I ever could.

https://yonatankra.com/layout-reflow/

johnson-jd avatar Feb 11 '21 18:02 johnson-jd

I now understand the reason behind using the non-passive event listener. I'm ok with it because the decision to prevent scrolling while dragging is legit.

Thanks @johnson-jd for the external link. It was a nice read.

dragonitaq avatar Feb 16 '21 12:02 dragonitaq

Close the issue due to the major version update. Feel free to create a new issue or open a new discussion.


Solved in v3.

NaotoshiFujita avatar Oct 09 '21 16:10 NaotoshiFujita