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

  • Home
  • SEARCH
  • 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 9317373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:51:45+00:00 2026-06-19T02:51:45+00:00

There are two ways that I would use to show/hide content: Create/destroy elements when

  • 0

There are two ways that I would use to show/hide content:

  1. Create/destroy elements when needed/not needed by using jQuery.append() and jQuery.remove().
  2. Have everything already in the html but hide/disable those elements when appropriate.

So what’s considered best practice? I can see advantages/disadvantages with both methods.

As an example, I have a site where people can shoot a picture with their webcam. The window in which the webcam resides is showed in a separate window overlapping all other content of the site. When a picture is taken the webcam overlapping is removed again. So I can hide it or insert/remove it.

  • 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-19T02:51:46+00:00Added an answer on June 19, 2026 at 2:51 am

    There is an in between approach that can take the best of each one of the approaches you mentioned. You mentioned creating and destroying elements using append and remove. It must be made clear that creating an element is a different task from attaching it to the DOM. ie

    creating a div

    var node = $('<div>node content</div>); 
    

    is different than attaching a div:

    parent.append(node);
    

    So what you can do is simply assign your elements to variables (ie cache them onto variables) and then attach them and detach them as appropriate. This way you don’t have to create the same element everytime you want to use it after having destroyed it (thus incurring a redundant processing cost).

    At the same time, you won’t have to attach it to the DOM tree unnecessarily then hide it (ie while not using it, thus incurring a UI/UX cost by making the overall experience slower b/c the page is loaded with nodes, some of which aren’t used at all by the user).

    I think that’s the best approach.

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

Sidebar

Related Questions

From previous post, I learnt that for there are two ways, at least, to
There's two ways of storing an NSDate in NSUserDefaults that I've come across. Option
I've noticed that there are two different ways to load nib/xib files: via the
I was tasked to create code that would fetch data from database using data
So I've noticed that there seem to be two ways to get the same
I was looking at some lint errors and notice that there are two ways
When defining fields in a django model, there are two ways to say that
There are two ways to overload operators for a C++ class: Inside class class
There are two ways to write a polymorphic migration in Rails. Generally, I've done
I know there are two ways, [self.navigationController pushViewController:siteViewController animated:YES]; [self presentModalViewController:anotherViewController animated:YES]; However, those

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.