Skip to content

Stimulus action @window or @document equilvalent? #312

Answered by keithamus
100phlecs asked this question in Q&A
Discussion options

You must be logged in to vote

We wanted to avoid global event listeners as we find they often do more harm than good, for the most part. There seems to be two common classes of global event listeners:

  • Using broad event delegation, e.g. listening for click on the window and checking the target. Event delegation is a good performance optimisation but can often be a premature one. Should a need arise for an element to have such an optimisation, it's probably good to state it explicitly. We don't want people to think it's the default. Adding a shorthand encourages this approach, we'd prefer to discourage it, as it comes with additional complexities (checking target, overly noisy callbacks, bubbling, propagation ordering,…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by keithamus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #311 on May 10, 2023 09:26.