Bootstrap 5 Popover JS (extends Tooltip + Popper.js) vs Native Popover API + CSS Anchor Positioning
Uses bootstrap.Popover (extends Tooltip) + Popper.js — creates DOM template, sanitizes HTML via TemplateFactory + Sanitizer, runs createPopper() for positioning on every show.
Uses Popover API (popover="auto") + CSS Anchor Positioning — browser handles toggle, light-dismiss, top-layer stacking, and positioning. Zero JavaScript.
| Metric | Bootstrap Popover | Native Popover API |
|---|---|---|
| Initialization time (100 instances) | - | - |
| Toggle time (10 cycles × 100 items) | - | - |
| Instance memory cost (100 instances) | - | - |
|
JS code size
popover.js (2.6 KB) +
tooltip.js (18.0 KB) +
template-factory.js (4.6 KB) +
sanitizer.js (3.8 KB) +
@popperjs/core
(19.7 KB min)
|
- | - |
|
CSS output size
_popover.scss (6.7 KB)
|
- | - |
data-bs-toggle="popover"
popover="auto" + CSS Anchor
createPopper() on every show, creates a new popover
<div> via TemplateFactory, sanitizes its HTML content
via Sanitizer, and runs JavaScript to calculate offsets and apply inline
transform styles. Native Popover API elements are already in the DOM
— the popover="auto" attribute provides click-to-toggle and light-dismiss
for free. CSS Anchor Positioning handles placement — zero JavaScript required.
<!-- Trigger button -->
<button style="anchor-name: --my-pop-trigger;"
popovertarget="my-popover">
Toggle popover
</button>
<!-- Popover (Bootstrap utility classes for styling) -->
<div popover="auto" id="my-popover"
class="p-0 border rounded shadow bg-white"
style="position-anchor: --my-pop-trigger;">
<div class="px-3 py-2 bg-body-secondary border-bottom fw-semibold small">Title</div>
<div class="px-3 py-2 small">Popover content here.</div>
</div>
[popover] {
inset: auto; /* reset UA default */
position-area: bottom span-right; /* place below trigger */
}