1

I have a big data enclosed in div.using some priority of log in I will make visible or invisible(using javascript). But my question is which property, whether visibility or display none is better for fast loading of page?

4 Answers4

4

The properties visibility and display are not the same.

Visibility hides the element but it will continue to affect the layout of the page.

Display will hide the element and will not affect the layout.

In terms of speed, the difference would be negligible. So you should focus on which affects the usability of the site.

Kami
  • 19,134
  • 4
  • 51
  • 63
0

the difference is that visibility keeps the space of the element as if it was displayed you just dont see it, display none means it's not displayed at all

john Smith
  • 17,409
  • 11
  • 76
  • 117
0

When you make an object invisible it will still occupy space in the layout. However, if you set the display to none, it will be hidden and ignored in the layout.

Tom
  • 4,422
  • 3
  • 24
  • 36
0

While display:none should be slightly faster, because the browser doesn't have to make the calculations to fit that element in the flow of the page, in reality this is only true if you're making lots of after-loading changes to the width/height of the element with JavaScript.