Performance: Landing page sections
Landing page sections affect the initial page load speed and visual stability as they determine how much content and styling the browser must process before showing the main content.
<section class="container"><div class="row align-items-center"><div class="col-md-6"><img src="optimized-image1.webp" loading="lazy" class="img-fluid" alt="Description"></div><div class="col-md-6"><h2>Title 1</h2><p>Some text here.</p></div></div></section>
<section class="container"><div class="row"><div class="col-12"><img src="large-image1.jpg" class="img-fluid" alt="Description"><h2>Title 1</h2><p>Some text here.</p></div></div></section><section class="container"><div class="row"><div class="col-12"><img src="large-image2.jpg" class="img-fluid" alt="Description"><h2>Title 2</h2><p>More text here.</p></div></div></section>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple large images without lazy loading | High (many nodes) | Multiple reflows per section | High paint cost due to images | [X] Bad |
| Optimized images with lazy loading and balanced grid | Moderate (fewer nodes) | Single reflow per section | Lower paint cost | [OK] Good |
container class creates a responsive fixed-width container that adapts to screen sizes, perfect for landing page sections.container-fluid spans full width always, row and col are for grid layout inside containers.<section class="container text-center py-5"> <h1>Welcome</h1> <p>Your journey starts here.</p> </section>
container centers content horizontally with fixed width, text-center centers text, py-5 adds vertical padding top and bottom.<section class="container text-center py-5"> <h2>Features</h3> <p>Easy to use and responsive.</p> </section>
<h2> but closes with </h3>, which is invalid HTML and causes rendering errors.bg-primary and padding to the <section> ensures the background color spans full width.text-center on the section centers text. Wrapping content inside a container keeps it aligned and responsive.btn-lg for larger size and scales well on small screens with Bootstrap's responsive utilities.Pass the test and this pattern moves unknown