Skip to content

Polling only if browser tab has focus? #821

Answered by jedie
jedie asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, i found a solution here: #525 (comment)

But how to combine this with polling?

EDIT2: A good solution seems to be:

hx-trigger="every 2s [document.visibilityState === 'visible'], visibilitychange[document.visibilityState === 'visible'] from:document"
  • Poll every 2 sec only if the page is visible
  • Poll immediately after the page gets visible

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jedie
Comment options

Answer selected by jedie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant