Add maxIdlePeriod
Hi!
Thanks for a great package.
This PR adds maxIdlePeriod that forces provider to load on browsers that support requestIdleCallback but do not manage to call it in reasonable time (defaults at 5s). This introduces a workaround for when the requestIdleCallback is never called because of infinite animations etc.
P.S. Have this published at @nedomas/[email protected] in npm in case it takes longer to review/push new official version.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-live-chat-loader | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 7, 2024 11:56pm |
Hey @Nedomas, thanks for submitting the PR.
During review we discussed if this change is viable for the library.
After all, the design of the library is that third parties aren't needlessly loaded if the user hasn't indicated to use it (by hovering over the widget init button), or finally if the page has been idle for a reasonable amount of time.
The question to be asked here is: If the page is never idle AND the user doesn't interact with the widget, why would we load it?
The change in this PR adds maxIdlePeriod to simply load when the deadline timer is reached (with a default of 5 seconds), which means third parties would always load after 5 seconds.
Hi @benschwarz thanks for the response! And yeah, I understand your point.
For me personally, there are two reasons why I need this:
- I’m loading widgets in page that never becomes idle (inside Shopify adming embedded env which constantly pings home, so it never idles properly).
- Automations like showing an onboarding message on first visit or some other automation defined in HelpScout or Intercom will never run unless the user interacts with the widget. This is not always the desired behaviour. In my case, it makes sense for some automations to run without user interaction.
Just my 2 cents. Thanks for the lib!