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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:34:40+00:00 2026-05-12T05:34:40+00:00

Similar to this question: JQuery: Build HTML in 'memory' rather than DOM I have

  • 0

Similar to this question:
JQuery: Build HTML in 'memory' rather than DOM

I have a

var $container = $("#container");

I also have:

jQuery.fn.somedomedits = function(expr) {
    return this.each(function() {
        var $self = $(this);
        $self.find(".adsf").append("<div></div>");
        // A lot more complex dom insertions like this
    });
};

Right now I’m doing:

$container.somedomedits().somemoredomedits();
// The somemoredomedits method is a similar plugin to the first one.

Just doing it this way changes DOM directly.

so then I did:

var $editeddom = $container.somedomedits().somemoredomedits();
$containerwrapper.html($editeddom);

Is that the correct way to do this?

I see no speed improvements in Firebug/fox, not sure if it would benefit other browsers.

Thanks

  • 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-12T05:34:40+00:00Added an answer on May 12, 2026 at 5:34 am

    This code is slower

    var $editeddom = $container.somedomedits().somemoredomedits();
    $containerwrapper.html($editeddom);
    

    because it’s doing the same as the

    $container.somedomedits().somemoredomedits();
    

    plus assign variable and run one extra method (html()).

    This would be faster if you were creating elements on-the-fly and inserting them to DOM tree after the whole structure is ready, but if you are getting elements out of DOM with the jQuery selector you get an object which still “points out” DOM. Assigning that to variable doesn’t make it clone automatically.

    You could clone this object and then run modification on the clone and after you are done replace the content but you should check first if cloning would be faster then what you are losing working on DOM directly.

    // clone part of DOM
    // .clone(true) clones event handlers as well if you don't need it
    // you can just run .clone()
    var items = $(selector).clone(true);
    
    // perform your complex operations
    items.somedomedits().somemoredomedits();
    
    // replace part of DOM with modified clones
    $(selector).replaceWith(items);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 148k
  • Answers 148k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Many people will only need this tool once in a… May 12, 2026 at 9:19 am
  • Editorial Team
    Editorial Team added an answer Enumerable.Where takes Func<T, bool>. Queryable.Where takes Expression<Func<T, bool>>. You're calling… May 12, 2026 at 9:19 am
  • Editorial Team
    Editorial Team added an answer No. A dl allows only two kinds of children: dt… May 12, 2026 at 9:19 am

Related Questions

Is there any built in support in jQuery for basic assertion checking, primarily of
I've been trying to understand what's the optimal way to do Ajax in Django
I'm trying to build a jQuery plugin that filters the provided jQuery object to
I have tried finding a simialr example and using that to answer my problem,
I'm trying to build a reusable $.ajax method for my current application but I'm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.