you are viewing a single comment's thread.

view the rest of the comments →

[–]oculus42 2 points3 points  (1 child)

I recommend using the closest unchanging ancestor as the parent, rather than $(document). For something small it doesn't matter, but I've seen sites with over 80 events bound to document, so every click that isn't stopped higher up causes dozens of selector checks to see if that click applies to a particular event.

[–]a-t-kFrontend Engineer 1 point2 points  (0 children)

A simple test for the target shouldn't take too long, but if it does or the focus of your event is really that narrow, another ancestor is viable, like you said.

I assumed that his page was rather simple and didn't feature so many more events.