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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:39:49+00:00 2026-06-10T10:39:49+00:00

Which is one more expensive to call? showing-hiding dom node or creating-deleting dom node

  • 0

Which is one more expensive to call?

  1. showing-hiding dom node or
  2. creating-deleting dom node

Assume there is only 1 dom or a few (less than 5) nodes that we need to manipulate and the application runs on desktop.

For a small number, does it even matter at all?
How about for mobile applications?

  • 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-10T10:39:51+00:00Added an answer on June 10, 2026 at 10:39 am

    The difference between the two will be infinitesimally small for only a few elements — it could absolutely be considered negligible.

    That being said, showing and hiding the element via CSS will be faster unless you use jQuery’s .show() and .hide(). jQuery’s .hide() is much slower than any other method of hiding an element. If you’d like to know why, read the “Why is .hide() slower?” section at the bottom of my answer.

    Anyway, you should make your decision based on which method suits your needs best. If you don’t ever need the element again, you may as well delete it. If you just wan’t to hide it for a little while or under certain conditions, show/hide it.

    But if you want to test it yourself, here ya go 🙂


    Why is .hide() slower?

    jQuery’s .hide() is basically the same as using .css('display','none') except that it caches the previous value of the display style, so that when you call .show(), your element will be correctly reverted to look the exact same as it did. If it had display:inline, it’ll have it when it gets re-shown. If it had display:block, it’ll have display:block. This can be pretty useful.

    Here’s an example:

    lets say we have a div with id=”myDiv” and it is styled in an external file with display:inline. We want to hide it.

    With the .css way, we’d do this:

    $('#myDiv').css('display','none');
    

    and then later on sometime, one of your fellow developers wants to show it again under certain conditions. He’ll have no idea what the display property should be, since the css is in an external file somewhere. Most developers default to display:block, like this:

    $('#myDiv').css('display','block');
    

    However in this case, we’d get a totally different style, since it was originally inline. A clever developer will have no problem figuring out what went wrong, but not all developers are clever 🙂

    With .show() and .hide(), this becomes a non issue. We don’t care what style it used to have. We just want it to be back where it was, and that’s exactly what it’ll do.

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

Sidebar

Related Questions

In general, which is more expensive? A double-nested for loop and one call to
I am creating an application for the iPhone which involves having more than one
Which one is more acceptable (best-practice)?: namespace NP public static class IO public static
I'd like to select all rows from one table which match one or more
Which one of these would be more suitable for RLE on bytes? I need
Which one is preferable or more clear? public int FrozenRegionWidth { get; set; }
Which is the best way to manage a website with one or more mirrors
I have a Sandbox which contains plenty of items composed of one or more
When Resharper argues with itself, how does one know which persona to give more
I am learning JPA and have one question: In which situations we need more

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.