Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there performance penalty for div tree depth?

Is there performance difference between:

    <div>
      <a> ... </a>
    </div>

and:

<div>
  <div>
    <div>
      <a> ... </a>
    </div>
   </div>
 </div>

For Browsers I think it doesn't make sense but in my case I have list of 200 items that run on mobile.

So I pretty sensitive to performance.

Thanks,

like image 692
snaggs Avatar asked Dec 25 '22 09:12

snaggs


1 Answers

Yes, there are some potential performance issues. You should consider:

  • Download time. More HTML means a larger file, which takes longer to download.

  • DOM size. More elements means that the page uses more memory.

  • Rendering time. More elements means that the page is drawn more slowly.

What you would notice most is normally the download time. If the page is still reasonbly small you should be ok. If you are creating a lot of elements dynamically, then the other two could be noticable without the loading time being the problem.

As few as 200 items shouldn't be a big problem though.

like image 56
Guffa Avatar answered Dec 28 '22 05:12

Guffa