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 777709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:39:01+00:00 2026-05-14T19:39:01+00:00

why do programmers say that live is inefficient? So what are the alternative methods

  • 0

why do programmers say that “live” is inefficient?

  1. So what are the alternative
    methods to replicating that function
    that are more efficient?
  2. How do we measure the impact of how much it slows things down?
  • 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-05-14T19:39:02+00:00Added an answer on May 14, 2026 at 7:39 pm

    I suppose it is inefficient because the handler is placed at the root node, and relies on bubbling to catch the event and run the proper handler.

    One alternative would be to simply bind your handler to your dynamically created elements when they are created and added to the DOM.

    Another alternative is to bind a single handler to a container, and let your events bubble up to that. This can be nice if you have lots of identical elements added to a container.

    <div id="myContainer">
        <div class="myElement>element</div>
        <div class="myElement>element</div>
        <div class="myElement>element</div>
        <div class="myElement>element</div>
    </div>
    

    Bind a click handler to #myContainer instead of each .myElement.

    $('#myContainer').click(function(e) {
        $target = $(e.target);
        if($target.closest('.myElement').length) {
            // Run my code for the click
        }
    });
    

    I image this may suffer from some of the same inefficiencies as .live(), but ought to be better as it is more localized. New .myElement items added, automatically work.


    EDIT:

    According to the docs: As of jQuery 1.4, event bubbling can optionally stop at a DOM element “context”.

    This would seem to create a similar effect to the last method I mentioned.


    EDIT:

    As suggested by Nick Craver, jQuery’s .delegate() method can produce a similar effect more cleanly.

    Example courtesy of Nick:

    $('#myContainer').delegate('.myElement', 'click' function() { alert($(this).text()); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programmers often whine that if only they had a faster/more memory/more cores machine they
Many programmers say it is a bad practice to use the eval() function: When
Before saying anything I have to say that, albeit I'm an experienced programmer in
Let's say you're the lucky programmer who inherited a code that is close to
Let's say I have programmers and artists working on a project. The artists have
Question fellow programmers. Let's say I have a stand alone application in it's own
(This is a hypothetical question for discussion, I have no actual problem). Say that
Are there any tools out there to help programmers that REALLY want type safety
What do functional programmers mean when they say a certain thing is composable or
Let's say I am creating an instance of a class object that has both

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.