Bootstrap JS vs Native Browser API Benchmarks

Interactive benchmarks comparing Bootstrap 5.3.8 JavaScript components against native browser API equivalents. Each benchmark measures initialization time, operation speed, memory usage, DOM mutations, and code size.

Best results in Chromeperformance.memory API is Chrome-only. Other metrics work across all modern browsers.
Collapse

Bootstrap Collapse JS (270 lines, scrollHeight calc) vs native <details>/<summary> (zero JS).

50 items × 100 toggle cycles

Offcanvas

Bootstrap Offcanvas JS (638 lines with utils) vs native <dialog> element.

500 open/close cycles

Dropdown

Bootstrap Dropdown JS (988 lines + Floating UI) vs native Popover API + CSS Anchor Positioning.

20 dropdowns × 100 cycles

Tooltip

Bootstrap Tooltip JS (745 lines + Floating UI) vs native Popover API.

200 tooltips, sequential trigger

Popover

Bootstrap Popover JS (111 lines + Tooltip parent) vs native Popover API.

100 popovers, sequential trigger

Toast

Bootstrap Toast JS (class toggler + timer + 41 KB infra) vs native Popover API (popover="manual").

20 toasts × 100 show/hide cycles

Accordion

Bootstrap Accordion JS (Collapse + data-bs-parent + 41 KB infra) vs native <details name=""> exclusive accordion.

10 groups × 5 items × 100 switch cycles

Carousel

Bootstrap Carousel JS (slide engine + touch/swipe + ~50 KB infra) vs native CSS scroll-snap (zero JS).

10 carousels × 5 slides × 100 slide cycles

Tab

Bootstrap Tab JS (panel switcher + ARIA + 43 KB infra) vs native <details name=""> exclusive accordion.

20 groups × 4 tabs × 100 switch cycles

ScrollSpy

Bootstrap ScrollSpy JS (config parser + event system + 44 KB infra wrapping IO) vs native IntersectionObserver (~15 lines).

20 containers × 10 sections × 50 scroll cycles

Form Validation

Bootstrap .was-validated / .is-invalid JS class toggling vs native :user-valid / :user-invalid (zero JS).

50 fields × 100 toggle cycles


NEW Native Browser APIs Not in Bootstrap JS

Modern browser APIs that could replace Bootstrap’s JavaScript with zero JS — but aren’t used yet.

Invoker Commands

<button commandfor="dialog" command="showModal"> — toggle dialogs, popovers, and fullscreen via HTML attributes. Zero JS event listeners.

Replaces: data-bs-toggle + event handler infrastructure

View Transitions API

Smooth animated transitions between DOM states with document.startViewTransition(). Works across same-document and cross-document navigations.

Replaces: manual JS animation in Tab, Carousel, page transitions

Scroll-driven Animations

Tie CSS animations to scroll position with animation-timeline: scroll() / view(). No scroll event listeners or requestAnimationFrame.

Replaces: ScrollSpy scroll listeners + offset calculations

aria-busy Loading Indicator

Set aria-busy="true" on any HTML element to show a loading spinner via CSS. One native attribute — no custom classes, no JS. Fully accessible.

Replaces: JS spinner libraries, custom loading components

Customizable <select>

Style native <select> dropdowns with CSS via appearance: base-select — custom options, icons, search. No JS dropdown reconstruction.

Replaces: JS-based custom select/dropdown components

CSS Anchor Positioning

Position tooltips, popovers, and dropdowns relative to a trigger element — no Floating UI or JS offset math needed.

Replaces: Floating UI in Dropdown, Tooltip, Popover

@starting-style

Define starting values for CSS transitions when elements first appear — fade-in popovers, slide-in dialogs, animate from display:none. Zero animation JS.

Replaces: .fade + .show JS class toggling in Modal, Offcanvas, Toast

:has() CSS Selector

Select parent elements based on their children — the “parent selector” CSS never had. Replaces JS DOM queries and class toggling.

Replaces: JS form validation, parent state toggling, layout detection

content-visibility: auto

Skip rendering offscreen content until the user scrolls to it. Two CSS properties replace IntersectionObserver boilerplate entirely.

Replaces: IntersectionObserver (~50–100 lines), virtual scrolling libraries

Navigation API

A modern replacement for the History API — intercept, manage, and navigate SPA “pages” with a single event listener. No router library needed.

Replaces: History API pushState/popstate, SPA router libraries


Native HTML & CSS Features

Built-in HTML elements and CSS capabilities that improve performance and UX — no JavaScript required.

Responsive Images

<picture>, srcset, and sizes — browser selects the optimal image for every device: resolution, viewport, and format. Zero JS.

Replaces: single <img src> + .img-fluid CSS-only scaling


Reports

Static analysis reports for the Bootstrap codebase.

ast-grep Report

Structural code pattern analysis using ast-grep — finds code patterns across the Bootstrap source.

ESLint Report

JavaScript linting report — code quality, style, and potential issues found by ESLint.

Stylelint Report

CSS linting report — style issues, best practices, and potential problems found by Stylelint.

jscpd Report

Copy/paste detection report — duplicated code blocks found across the Bootstrap source by jscpd.


Using Bootstrap 5.3.8 from jsDelivr CDN. Native API benchmarks use zero external JavaScript libraries.