Performance: Nested lists
MEDIUM IMPACT
Nested lists affect the DOM size and complexity, impacting rendering speed and layout calculations.
<nav aria-label="Main menu"> <ul> <li><button aria-expanded="false" aria-controls="submenu1">Item 1</button> <ul id="submenu1" hidden> <li>Subitem 1</li> <li>Subitem 2</li> </ul> </li> <li>Item 2</li> </ul> </nav>
<ul> <li>Item 1 <ul> <li>Subitem 1 <ul> <li>Subsubitem 1</li> <li>Subsubitem 2</li> </ul> </li> <li>Subitem 2</li> </ul> </li> <li>Item 2</li> </ul>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deeply nested lists | High number of nodes and deep tree | Multiple reflows triggered during layout | High paint cost due to many elements | [X] Bad |
| Shallow lists with hidden submenus | Fewer nodes initially, hidden elements reduce layout | Single reflow on load | Lower paint cost | [OK] Good |