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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:09:41+00:00 2026-05-25T18:09:41+00:00

I am learning DOM manipulation with jQuery and want to understand browser performance best

  • 0

I am learning DOM manipulation with jQuery and want to understand browser performance best practices.

Say I have two DOM elements (div, p, ol, etc) and I want a user to only see the first element and then only see the second element.

I could:

  1. Use replace()
  2. remove() the first element and add() the second element
  3. hide() the first element and show() the second element

What is the performance differences between:

  • 1 vs. 2
  • 2 vs. 3
  • 1 vs. 3

Are there additional performance considerations if the elements are of different types? Or if the elements are buttons or form fields?

  • 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-25T18:09:41+00:00Added an answer on May 25, 2026 at 6:09 pm

    Removing and adding elements to the DOM is expensive in terms of resources because of browser reflow, where the browser must re-render part or all of the page. You want to avoid reflows whenever you can; they are costly.

    Replacing is essentially a removal then an addition, so the above applies.

    Showing and hiding is best, because it is only adding styles to the elements.

    The type of elements you’re applying these methods too should not lead to a change in the above.

    In conclusion, use .show() and .hide() for best performance.

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

Sidebar

Related Questions

Learning XML Schema, I want to be able to have collections of elements inside
The book Learning jQuery says IE has memory leak for the DOM object having
Learning .NET: I have a form with a split container, I want to load
learning Jquery and integrating with PHP - getting there, but have one last challenge
I'm learning how to appending DOM nodes with Javascript and have a little clarification
I am learning JQuery. I have a need to create a custom control. This
I am just starting out learning JavaScript and I have just reach the DOM
I am learning the Java XML API. I am using DOM. I have a
Learning a lot in my few years of programming that the best projects are
I am learning about DOM collections. The textbook I'm using had the following Javascript

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.