Performance: Offcanvas component
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by adding hidden panels that slide in and out without reloading the page.
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvasSidebar" aria-labelledby="offcanvasSidebarLabel"> <div class="offcanvas-header"> <h5 id="offcanvasSidebarLabel">Menu</h5> <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button> </div> <div class="offcanvas-body"> <!-- lightweight content or lazy loaded --> </div> </div> <button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasSidebar" aria-controls="offcanvasSidebar"> Toggle Menu </button>
<div id="sidebar" style="display:none; position:fixed; left:0; top:0; width:300px; height:100vh; background:#fff; z-index:1050;"> <!-- heavy content with many images and scripts --> </div> <script> function toggleSidebar() { const sidebar = document.getElementById('sidebar'); sidebar.style.display = sidebar.style.display === 'none' ? 'block' : 'none'; } </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Display toggle with heavy content | High (many nodes) | 2+ per toggle | High (full repaint) | [X] Bad |
| Bootstrap offcanvas with transform | Moderate | 0 | Low (composite only) | [OK] Good |