launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
109 stars 62 forks source link

Lighthouse audit fails with `no-unload-listeners` #252

Open mkallies opened 2 years ago

mkallies commented 2 years ago

Is your feature request related to a problem? Please describe. We recently installed the React SDK. We run lighthouse-ci in our CI pipeline and it failed due to no-unload-listeners.

Describe the solution you'd like Based off of https://web.dev/bfcache/#never-use-the-unload-event, pagehide event is the recommended event since it's triggered in all cases where unload is triggered.

Describe alternatives you've considered For the time being we can ignore this error.

Additional context

Never add an unload event listener! Use the pagehide event instead. Adding an unload event listener will make your site slower in Firefox, and the code won't even run most of the time in Chrome and Safari.

kinyoklion commented 2 years ago

Hello @mkallies

Thank you for the report! We are aware of the issue with the bfcache and will be working on a solution soon.

filed internally as 147957

Thank you, Ryan

mkallies commented 1 year ago

@kinyoklion any updates on this? Another point to add is using launchdarkly + lighthouse-ci added 5 minutes to the run time. Not sure why

kinyoklion commented 1 year ago

Hey @mkallies,

I can't commit to a release date, but I can say that we have been working on this. Unfortunately there is a lot of inconsistency between browsers. So, the implementation itself isn't so much a problem, but validation is more complex.

Thanks, Ryan

alanayoub commented 1 year ago

Hello, any news on this one?

kinyoklion commented 1 year ago

Hey @mkallies, @alanayoub,

This has been released in 3.1.0: https://github.com/launchdarkly/js-client-sdk/releases/tag/3.1.0

We were able to validate the behavior recently and it should behave more consistently than the previous implementation.

Thanks for the patience.

Thank you, Ryan