T
9

The day I stopped nesting everything inside divs

For about 4 years I built every layout with divs inside divs inside more divs. Last month I had a 12 level deep structure just to show a card with an icon on the left and text on the right. A guy I was pair coding with asked why I wasn't using flex gap and a simple section. It took me a second to realize he meant I could skip 9 of those wrapper divs entirely. Now I gutted an old component from 38 elements down to 9 and it loads noticeably faster. Anyone else have a moment where their whole nesting habit just collapsed?
1 comments

Log in to join the discussion

Log In
1 Comment
barnes.kai
It's wild how this shows up everywhere once you notice it. I did the same thing with my kitchen cabinets last year, had like three organizers inside each other just to hold spices, then realized a single shelf and a label did the job better. We stack layers of stuff out of habit, not because they're adding anything real. Stripping it back to what actually works feels scary at first, then you wonder why you ever did it the other way.
2