Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:32:37+00:00 2026-06-02T06:32:37+00:00

I have two approaches in mind on how to apply jQuery’s event.stopPropagation() : Optimistic

  • 0

I have two approaches in mind on how to apply jQuery’s event.stopPropagation():

  1. Optimistic approach – By default, all event handlers are without stopPropagation(). stopPropagation() would be added to a handler only if there’s some unnecessary and undesired behaviour caused by event bubbling.
  2. Pessimistic approach – By default, stopPropagation() is added to all event handlers. If there’s some desired behaviour missing due to disconnected even bubbling, then the corresponding stopPropagation() would get removed.

I was wondering which one of the two, or neither, is the mindset I should have when utilizing stopPropagation() in my development. I am leaning more towards 2) because it looks like it would have better performance because unnecessary bubbling gets prevented. I would like to hear from experts on the topic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:32:38+00:00Added an answer on June 2, 2026 at 6:32 am

    Calling stopPropagation everywhere isn’t good. It breaks event delegation*, is probably less efficient unless you literally add handlers to every single element on the page (and if you’re doing that, you should be using event delegation), and you might not remember to do it.

    So rule of thumb: Only call stopPropagation when you need to do so.


    * That is, .live, .delegate, and the delegate version of .on.


    Here’s an example of event delegation, which relies on bubbling to listen for events that originate from elements added after the listener was created:

    document.documentElement.addEventListener('click', function(e) {
        if(e.target.nodeName === 'a') {
            console.log('A link was clicked!');
        }
    });
    

    Here’s somebody throwing in jQuery that breaks that:

    $('div').click(function(e) {
        e.stopPropagation();
    });
    

    Any <a> that is a descendant of a <div> will no longer get its clicks handled! Please don’t do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen two different approaches in saving user preferences. APPROACH 1: Serializing them
With this approach. I have a line plot graph. I want to plot 'two'
I have two jQuery elements, $link = $('<a>') and $input = $('<input/>') . Although
I have to keep in mind the priority of operations, all the numbers including
Have two folders with approx. 150 java property files. In a shell script, how
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two DropDownListBoxes one is called ddlDay and the other is ddlMonth. As
I have two application that need to talk to each other. App1 needs to
I have two methods -a and -b. -a calls sometimes -b, and -b sometimes
I have two classes generated by LINQ2SQL both from the same table so they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.