Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes Hide show vs inserting/deleting html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Hide show vs inserting/deleting html" Watch "Hide show vs inserting/deleting html" New topic
Author

Hide show vs inserting/deleting html

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

Hi,

I am using backbone js. I have a screen with two pages. I have two options I can render both pages at same time and then hide/show based on selection. Other thing is rendering each page separately. Second approach looks better to me and if I am not wrong. In both cases browser will have to re-paint? Please correct me if I am wrong.


Pawan Chopra
SCJP - DuMmIeS mInD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

"Better" has to be measured against some criteria or objective. What are you measuring against? Browser speed? Memory usage? Clarity of code?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

Bear Bibeault wrote:"Better" has to be measured against some criteria or objective. What are you measuring against? Browser speed? Memory usage? Clarity of code?


I am looking for good performance. So browser speed is what I am measuring against.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

OK, next question then: do you really think there will be a user-discernable difference between the approaches?

What I'm getting at is that if it were my project, I would first strive for code clarity, and then if, and only if, a performance issue arises, start looking at different approaches.

Is there a demonstrable performance problem you are trying to solve?
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 410

Bear Bibeault wrote:OK, next question then: do you really think there will be a user-discernable difference between the approaches?

What I'm getting at is that is it were my project, I would first strive for code clarity, and then if, and only if, a performance issue arises, start looking at different approaches.

Is there a demonstrable performance problem you are trying to solve?


Not really didn't have any issue till now. I am currently rendering instead of show/hide. I feel its clean and simple. Not sure if you agree with me. But other than that am I right that in both ways browser will re-paint?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Well, "repaint" isn't really a term often used with browsers, but yes, anything that changes the display will cause the browser to, well, change the display.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hide show vs inserting/deleting html