Performance: Carousel programmatic control
Controls how the carousel updates slides and animations, impacting interaction responsiveness and visual stability.
const carousel = bootstrap.Carousel.getInstance(document.querySelector('#myCarousel')); carousel.to(2);
const carousel = bootstrap.Carousel.getInstance(document.querySelector('#myCarousel'));
carousel.next();
carousel.next();
carousel.next();| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple sequential slide changes | Multiple class toggles on slides | Multiple reflows (one per slide change) | Multiple paints causing jank | [X] Bad |
| Direct jump to target slide | Single class toggle on target slide | Single reflow | Single paint with smooth animation | [OK] Good |
$('#myCarousel').carousel(2);document.getElementById('carouselExample').carousel('pause');Pass the test and this pattern moves unknown