简体   繁体   中英

large number of hidden divs in a pge

Will I have to face any problem if i have large number of hidden divs in my page ?? i mean that in my page there is a loop which contains some hidden divs and some buttons which when clicked shows one of the hidden div...

i just want to ask that will i have to face any problem with these hidden div.. the code here is just an example .... any help will be appreciated.. thanks in advance

<?php
    for ( $a = 1; $a < 10; $a++ ) {
      <div style='display:none'>
         content goes here....
      </div>
  }
?>

I have many pages with over half a million divs that work fine. Probably the most important thing with many hidden divs is that you enclose the hidden divs within another element which is of fixed layout. If you have a massive amount of html and a fluid layout and you change the visibility of an element, the browser must calculate all the layout again which can be slow and give the user poor responsiveness.

No problem! But if you are having more and more your websites load will be heavy. That might cause slower performance and perhaps hangs up. It would take loading time too..

No problem! but It will be indexed but can be frowned upon by Google if you are hiding/showing content for SEO reasons. In other words, what Google sees should be what the user sees when clicking the link.

That depends on what you try to do. If you fill your hidden divs with images and other heavy stuff, it all will be loaded immediately with page and may slow things down. Also, browsers would still take time for parsing everything you hid (but that is actually not much time).

So, if you are talking about like 1000x1000 grid of buttons or something like that (for making kind of a game maybe), it will result in sad performance.

If you are talking about dynamic loading of a lot of heavy content, like a whole facebook timeline, it won't work well neither.

But if you just want to show users some blocks, which would work okay if you didn't hide it at all, you will have no problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM