Most demos need a newer browser

They use :has() and container queries. Update your browser, or on an iPhone update iOS to 16.4 or later.

JavaScript Carousel Slider vs CSS

Slick's carousel slider and the CSS version, both with five slides. Slick runs in a sandboxed frame, CSS on the page.

CSS

scroll snap with ::scroll-button(*) and ::scroll-marker

Wins overall6 wins4 ties1 loss

On the laptop test, all 11 measures

Wins overall7 wins3 ties1 loss

On the slow phone test, all 11 measures

Wins overall6 wins5 ties0 losses

On the busy page test, all 11 measures

Wins2.2 KBdownload size, gzipped

Slick

Slick 2.0.0

Loses overall1 win4 ties6 losses

On the laptop test, all 11 measures

Loses overall1 win3 ties7 losses

On the slow phone test, all 11 measures

Loses overall0 wins5 ties6 losses

On the busy page test, all 11 measures

Loses44.3 KBdownload size, gzipped

38.1 KB of JavaScript, from jQuery 4.0.0 and Slick 2.0.0.

Test condition

Who wins

CSS winsTieCSS loses

  • Against Slick

    CSS wins 6, ties 4, loses 1

    CSS wins: 6 of 11 measures, against Slick, laptop6Tie: 4 of 11 measures, against Slick, laptop4CSS loses: 1 of 11 measures, against Slick, laptop1
  • Against Vanilla JS

    CSS wins 4, ties 6, loses 1

    CSS wins: 4 of 11 measures, against Vanilla JS, laptop4Tie: 6 of 11 measures, against Vanilla JS, laptop6CSS loses: 1 of 11 measures, against Vanilla JS, laptop1
  • Against Slick

    CSS wins 7, ties 3, loses 1

    CSS wins: 7 of 11 measures, against Slick, phone, 4x slower7Tie: 3 of 11 measures, against Slick, phone, 4x slower3CSS loses: 1 of 11 measures, against Slick, phone, 4x slower1
  • Against Vanilla JS

    CSS wins 4, ties 7, loses 0

    CSS wins: 4 of 11 measures, against Vanilla JS, phone, 4x slower4Tie: 7 of 11 measures, against Vanilla JS, phone, 4x slower7
  • Against Slick

    CSS wins 6, ties 5, loses 0

    CSS wins: 6 of 11 measures, against Slick, busy page6Tie: 5 of 11 measures, against Slick, busy page5
  • Against Vanilla JS

    CSS wins 4, ties 7, loses 0

    CSS wins: 4 of 11 measures, against Vanilla JS, busy page4Tie: 7 of 11 measures, against Vanilla JS, busy page7

Tie: the middle half of runs overlap, or the medians sit under 16.7 ms apart (one frame at 60 frames a second). Bytes and lines compare exactly. While both layout shift scores are under 0.1 (Google's line for good), the winner is slightly ahead at most.

Head to head

CSS on the left, Slick on the right, one measure per row. Green marks who wins, red who loses, gray a tie.

CSS

Slick

JavaScript downloadedCSS wins

0 KB38.1 KB

Everything downloadedCSS wins

2.2 KB44.3 KB

Script time while loadingCSS wins

0 ms36 ms

Time until it worksCSS wins

36 ms69 ms

Lines of codeCSS wins

15310,431

With JavaScript offCSS wins

WorksShows, clicks do nothing

Vanilla JavaScript: 1.8 KB of JavaScript, works at 37 ms, 253 lines to write, does not work with script off.

JavaScript downloadedCSS wins

0 KB38.1 KB

Everything downloadedCSS wins

2.2 KB44.3 KB

Script time while loadingCSS wins

0 ms232 ms

Time until it worksCSS wins

474 ms862 ms

Lines of codeCSS wins

15310,431

With JavaScript offCSS wins

WorksShows, clicks do nothing

Vanilla JavaScript: 1.8 KB of JavaScript, works at 466 ms, 253 lines to write, does not work with script off.

JavaScript downloadedCSS wins

0 KB38.1 KB

Everything downloadedCSS wins

2.2 KB44.3 KB

Script time while loadingCSS wins

0 ms35 ms

Time until it worksCSS wins

33 ms70 ms

Lines of codeCSS wins

15310,431

With JavaScript offCSS wins

WorksShows, clicks do nothing

Vanilla JavaScript: 1.8 KB of JavaScript, works at 34 ms, 253 lines to write, does not work with script off.

Laptop: 1280 x 800, no throttling. 15 runs per version in Chrome 157, Nov 25, 2026.

Phone, 4x slower: CPU 4x slower, slow 4G (150 ms round trip, 1.6 Mbps down, 750 kbps up), 390 x 844 at 2x. 15 runs per version in Chrome 157, Nov 25, 2026.

Busy page: 1280 x 800, other script holding the main thread for 50 ms of every 100 ms. 15 runs per version in Chrome 157, Nov 25, 2026.

Replace a JavaScript carousel slider using CSS

  1. 1Write the HTML structure

    Every rule in the stylesheet is scoped under .demo-scroll-carousel, so keep that wrapper or rename it in both files. Add or remove slides as your content requires.

    index.html22 lines

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Carousel: CSS scroll snap</title>
    <link rel="stylesheet" href="carousel.css">
    </head>
    <body>
    <div class="demo-scroll-carousel">
    	<div class="carousel-wrap">
    		<div class="carousel">
    			<div class="carousel-slide">Slide 1 of 5</div>
    			<div class="carousel-slide">Slide 2 of 5</div>
    			<div class="carousel-slide">Slide 3 of 5</div>
    			<div class="carousel-slide">Slide 4 of 5</div>
    			<div class="carousel-slide">Slide 5 of 5</div>
    		</div>
    	</div>
    </div>
    </body>
    </html>
  2. 2Create the scrolling and snapping behavior

    overflow-x: auto on .carousel makes the row scroll, and scroll-snap-type: x mandatory stops it on a slide. scroll-behavior: smooth animates the arrow and dot moves in Chrome and Edge. The colors by :nth-child() and the accessible names for the dots are written for exactly five slides.

    carousel.css131 lines

    /*
     * Carousel, CSS version: a scroll snap carousel with no script.
     * The arrows come from ::scroll-button() and the dots from ::scroll-marker (Chrome 135 and
     * later). The browser disables each arrow at its end and marks the dot for the slide in view.
     * Slides and colors are the ones on purecss.com/scroll-carousel/.
     * Icons: Font Awesome Free 7.3.1 arrow-left and arrow-right, CC BY 4.0,
     * https://fontawesome.com/license/free
     */
    
    /* The arrows are placed against the wrap, so it is the positioned box */
    .demo-scroll-carousel .carousel-wrap {
    	position: relative;
    	width: 100%;
    	max-width: 520px;
    	margin: 0 auto;
    }
    
    .demo-scroll-carousel .carousel {
    	display: flex;
    	overflow-x: auto;
    	scroll-snap-type: x mandatory;
    	scroll-behavior: smooth;
    	/* hands the scroller to the compositor, so the arrows' smooth scroll keeps moving while the
    	   page's main thread is busy (without it Chrome 157 scrolled this one on the main thread) */
    	will-change: scroll-position;
    	border-radius: 10px;
    	scrollbar-width: none;
    	/* the dots are drawn in a row after the carousel. With tabs, they are one Tab stop and the
    	   arrow keys move between them (plain "after" makes each dot its own Tab stop). The first
    	   line is a fallback, kept in case a browser reads "after" but not "after tabs" */
    	scroll-marker-group: after;
    	scroll-marker-group: after tabs;
    }
    
    .demo-scroll-carousel .carousel::-webkit-scrollbar {
    	display: none;
    }
    
    .demo-scroll-carousel .carousel-slide {
    	flex: 0 0 100%;
    	height: 160px;
    	scroll-snap-align: start;
    	/* a fast swipe stops at the next slide instead of flying past it */
    	scroll-snap-stop: always;
    	display: flex;
    	align-items: center;
    	justify-content: center;
    	font-size: 1.2rem;
    	font-weight: 700;
    	color: #0c0c0d;
    	-webkit-user-select: none;
    	user-select: none;
    }
    
    .demo-scroll-carousel .carousel-slide:nth-child(1) { background: #c084fc; }
    .demo-scroll-carousel .carousel-slide:nth-child(2) { background: #38bdf8; }
    .demo-scroll-carousel .carousel-slide:nth-child(3) { background: #ffd444; }
    .demo-scroll-carousel .carousel-slide:nth-child(4) { background: #57d9a3; }
    .demo-scroll-carousel .carousel-slide:nth-child(5) { background: #b8ff57; }
    
    /* Arrows. Each click scrolls one slide; the text after the slash is the button's name */
    .demo-scroll-carousel .carousel::scroll-button(*) {
    	/* a page's *::before, *::after reset does not reach these pseudo-elements */
    	box-sizing: border-box;
    	position: absolute;
    	/* half the slide height, so the arrow sits on the slide's middle */
    	top: 80px;
    	width: 40px;
    	height: 40px;
    	margin-top: -20px;
    	padding: 0;
    	border: 0;
    	border-radius: 50%;
    	background-color: rgba(24, 22, 29, .6);
    	background-position: center;
    	background-size: 16px 16px;
    	background-repeat: no-repeat;
    	cursor: pointer;
    }
    
    .demo-scroll-carousel .carousel::scroll-button(left) {
    	content: "" / "Previous slide";
    	left: 8px;
    	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23fff' d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288 480 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-370.7 0 105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z'/%3E%3C/svg%3E");
    }
    
    .demo-scroll-carousel .carousel::scroll-button(right) {
    	content: "" / "Next slide";
    	right: 8px;
    	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23fff' d='M502.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l370.7 0-105.4 105.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z'/%3E%3C/svg%3E");
    }
    
    /* the browser disables an arrow when there is no slide left in its direction */
    .demo-scroll-carousel .carousel::scroll-button(*):disabled {
    	opacity: .35;
    	cursor: default;
    }
    
    .demo-scroll-carousel .carousel::scroll-button(*):focus-visible {
    	outline: 2px solid #18161d;
    	outline-offset: 2px;
    }
    
    /* Dots: one marker per slide, in a 20px box with a 10px dot inside */
    .demo-scroll-carousel .carousel::scroll-marker-group {
    	display: flex;
    	justify-content: center;
    	gap: 10px;
    	height: 20px;
    	margin: 5px 0;
    }
    
    .demo-scroll-carousel .carousel-slide::scroll-marker {
    	content: "";
    	box-sizing: border-box;
    	width: 20px;
    	height: 20px;
    	border: 5px solid transparent;
    	border-radius: 50%;
    	background: rgba(24, 22, 29, .25) padding-box;
    	cursor: pointer;
    }
    
    /* the text after the slash names each dot for screen readers */
    .demo-scroll-carousel .carousel-slide:nth-child(1)::scroll-marker { content: "" / "Slide 1"; }
    .demo-scroll-carousel .carousel-slide:nth-child(2)::scroll-marker { content: "" / "Slide 2"; }
    .demo-scroll-carousel .carousel-slide:nth-child(3)::scroll-marker { content: "" / "Slide 3"; }
    .demo-scroll-carousel .carousel-slide:nth-child(4)::scroll-marker { content: "" / "Slide 4"; }
    .demo-scroll-carousel .carousel-slide:nth-child(5)::scroll-marker { content: "" / "Slide 5"; }
    
    /* the dot for the slide in view */
    .demo-scroll-carousel .carousel-slide::scroll-marker:target-current {
    	background-color: rgba(24, 22, 29, .75);
    }
    
    .demo-scroll-carousel .carousel-slide::scroll-marker:focus-visible {
    	outline: 2px solid #18161d;
    	outline-offset: 1px;
    }
    
    @media (prefers-reduced-motion: reduce) {
    	.demo-scroll-carousel .carousel {
    		scroll-behavior: auto;
    		transition: none;
    		animation: none;
    	}
    }

Test condition

CSS and Slick loading on the slow phone test, played 4x slower. CSS shows its carousel at first paint and works at once. Slick paints at 450 ms with slides stacked, then works at 862 ms once its script completes (medians of 15 runs).

The numbers

What each version downloads

Bytes downloadedCSS winsCSS winsCSS wins

Every file, gzipped. The solid part of a bar is JavaScript, the light part is HTML, CSS, images and fonts.

CSS
CSS: 2.2 KB, CSS 1.9 KB, HTML 0.3 KB
2.2 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.9 KB, JavaScript 1.8 KB, CSS 1.6 KB, HTML 0.6 KB
3.9 KB1.8 KB JavaScript
Slick
Slick: 44.3 KB, JavaScript 38.1 KB, CSS 2.5 KB, HTML 0.4 KB, Image or font 3.4 KB
44.3 KB38.1 KB JavaScript
KB
CSS
CSS: 2.2 KB, CSS 1.9 KB, HTML 0.3 KB
2.2 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.9 KB, JavaScript 1.8 KB, CSS 1.6 KB, HTML 0.6 KB
3.9 KB1.8 KB JavaScript
Slick
Slick: 44.3 KB, JavaScript 38.1 KB, CSS 2.5 KB, HTML 0.4 KB, Image or font 3.4 KB
44.3 KB38.1 KB JavaScript
KB
CSS
CSS: 2.2 KB, CSS 1.9 KB, HTML 0.3 KB
2.2 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.9 KB, JavaScript 1.8 KB, CSS 1.6 KB, HTML 0.6 KB
3.9 KB1.8 KB JavaScript
Slick
Slick: 44.3 KB, JavaScript 38.1 KB, CSS 2.5 KB, HTML 0.4 KB, Image or font 3.4 KB
44.3 KB38.1 KB JavaScript
KB

Download time on a slow phone connection

Worked out from the byte counts at the phone test's 1.6 Mbps download speed.

CSS
CSS: 11 ms, CSS 9.5 ms, HTML 1.5 ms
11 msbest
Vanilla JS
Vanilla JS: 19 ms, JavaScript 8.8 ms, CSS 7.8 ms, HTML 2.9 ms
19 ms
Slick
Slick: 222 ms, JavaScript 190 ms, CSS 13 ms, HTML 1.9 ms, Image or font 17 ms
222 ms
ms
See the numbers
Carousel, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: carousel.cssCSS1,9079.5 ms
CSS: index.htmlHTML3091.5 ms
CSS total2,21611 ms
Vanilla JS: carousel.jsJavaScript1,7668.8 ms
Vanilla JS: carousel.cssCSS1,5637.8 ms
Vanilla JS: index.htmlHTML5702.9 ms
Vanilla JS total3,89919 ms
Slick: init.jsJavaScript3031.5 ms
Slick: jquery.min.jsJavaScript27,530138 ms
Slick: slick.min.jsJavaScript10,24851 ms
Slick: carousel.cssCSS1,1845.9 ms
Slick: slick-theme.cssCSS8144.1 ms
Slick: slick.cssCSS5182.6 ms
Slick: index.htmlHTML3741.9 ms
Slick: ajax-loader.gifImage or font2,55613 ms
Slick: slick.woff2Image or font8204.1 ms
Slick total44,347222 ms

Time on slow 4G = bytes x 8 / 1,600,000 bits per second. Round trips and parsing are not counted.

CSS
CSS: 11 ms, CSS 9.5 ms, HTML 1.5 ms
11 msbest
Vanilla JS
Vanilla JS: 19 ms, JavaScript 8.8 ms, CSS 7.8 ms, HTML 2.9 ms
19 ms
Slick
Slick: 222 ms, JavaScript 190 ms, CSS 13 ms, HTML 1.9 ms, Image or font 17 ms
222 ms
ms
See the numbers
Carousel, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: carousel.cssCSS1,9079.5 ms
CSS: index.htmlHTML3091.5 ms
CSS total2,21611 ms
Vanilla JS: carousel.jsJavaScript1,7668.8 ms
Vanilla JS: carousel.cssCSS1,5637.8 ms
Vanilla JS: index.htmlHTML5702.9 ms
Vanilla JS total3,89919 ms
Slick: init.jsJavaScript3031.5 ms
Slick: jquery.min.jsJavaScript27,530138 ms
Slick: slick.min.jsJavaScript10,24851 ms
Slick: carousel.cssCSS1,1845.9 ms
Slick: slick-theme.cssCSS8144.1 ms
Slick: slick.cssCSS5182.6 ms
Slick: index.htmlHTML3741.9 ms
Slick: ajax-loader.gifImage or font2,55613 ms
Slick: slick.woff2Image or font8204.1 ms
Slick total44,347222 ms

Time on slow 4G = bytes x 8 / 1,600,000 bits per second. Round trips and parsing are not counted.

CSS
CSS: 11 ms, CSS 9.5 ms, HTML 1.5 ms
11 msbest
Vanilla JS
Vanilla JS: 19 ms, JavaScript 8.8 ms, CSS 7.8 ms, HTML 2.9 ms
19 ms
Slick
Slick: 222 ms, JavaScript 190 ms, CSS 13 ms, HTML 1.9 ms, Image or font 17 ms
222 ms
ms
See the numbers
Carousel, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: carousel.cssCSS1,9079.5 ms
CSS: index.htmlHTML3091.5 ms
CSS total2,21611 ms
Vanilla JS: carousel.jsJavaScript1,7668.8 ms
Vanilla JS: carousel.cssCSS1,5637.8 ms
Vanilla JS: index.htmlHTML5702.9 ms
Vanilla JS total3,89919 ms
Slick: init.jsJavaScript3031.5 ms
Slick: jquery.min.jsJavaScript27,530138 ms
Slick: slick.min.jsJavaScript10,24851 ms
Slick: carousel.cssCSS1,1845.9 ms
Slick: slick-theme.cssCSS8144.1 ms
Slick: slick.cssCSS5182.6 ms
Slick: index.htmlHTML3741.9 ms
Slick: ajax-loader.gifImage or font2,55613 ms
Slick: slick.woff2Image or font8204.1 ms
Slick total44,347222 ms

Time on slow 4G = bytes x 8 / 1,600,000 bits per second. Round trips and parsing are not counted.

Waiting before it works

Time until it worksTie with Vanilla JSTie with Vanilla JSTie with Vanilla JS

From the page start to the first click that works.

Nothing on screenOn screen, clicks do nothing yetWorks

CSS
CSS: first paint at 36 ms, works at 36 ms
36 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 37 ms, works at 37 ms
37 mstied bestworks when shown
Slick
clicks do nothing yetSlick: first paint at 32 ms, works at 69 ms, 37 ms when clicks do nothing
69 ms37 ms dead
ms from page start

With JavaScript off

CSS
WorksCSS with JavaScript off: works
Works
Vanilla JS
Does not workVanilla JS with JavaScript off: does not work
Never
Slick
Shows, clicks do nothingSlick with JavaScript off: shows, clicks do nothing
Never
See the numbers
Carousel, Laptop. Medians of 15 runs, from the start of the page load. JavaScript off was tested once on the laptop.
VersionFirst paintWorks atClicks do nothing forJavaScript off
CSS36 ms36 ms0 msWorks
Vanilla JS37 ms37 ms0 msDoes not work
Slick32 ms69 ms37 msShows, clicks do nothing

Nothing on screenOn screen, clicks do nothing yetWorks

CSS
CSS: first paint at 474 ms, works at 474 ms
474 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 460 ms, works at 466 ms, 5.2 ms when clicks do nothing
466 mstied best5.2 ms dead
Slick
clicks do nothing yetSlick: first paint at 450 ms, works at 862 ms, 412 ms when clicks do nothing
862 ms412 ms dead
ms from page start

With JavaScript off

CSS
WorksCSS with JavaScript off: works
Works
Vanilla JS
Does not workVanilla JS with JavaScript off: does not work
Never
Slick
Shows, clicks do nothingSlick with JavaScript off: shows, clicks do nothing
Never
See the numbers
Carousel, Phone, 4x slower. Medians of 15 runs, from the start of the page load. JavaScript off was tested once on the laptop.
VersionFirst paintWorks atClicks do nothing forJavaScript off
CSS474 ms474 ms0 msWorks
Vanilla JS460 ms466 ms5.2 msDoes not work
Slick450 ms862 ms412 msShows, clicks do nothing

Nothing on screenOn screen, clicks do nothing yetWorks

CSS
CSS: first paint at 33 ms, works at 33 ms
33 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 34 ms, works at 34 ms
34 mstied bestworks when shown
Slick
clicks do nothing yetSlick: first paint at 32 ms, works at 70 ms, 38 ms when clicks do nothing
70 ms38 ms dead
ms from page start

With JavaScript off

CSS
WorksCSS with JavaScript off: works
Works
Vanilla JS
Does not workVanilla JS with JavaScript off: does not work
Never
Slick
Shows, clicks do nothingSlick with JavaScript off: shows, clicks do nothing
Never
See the numbers
Carousel, Busy page. Medians of 15 runs, from the start of the page load. JavaScript off was tested once on the laptop.
VersionFirst paintWorks atClicks do nothing forJavaScript off
CSS33 ms33 ms0 msWorks
Vanilla JS34 ms34 ms0 msDoes not work
Slick32 ms70 ms38 msShows, clicks do nothing

Main thread while loading

Blocking timeTie with Vanilla JSTie with Vanilla JSTie with Slick

The main thread's tasks in one typical run. A long task blocks any click that arrives during it.

Main thread taskPart past 50 ms: a long task

CSS
CSS: task at 7.3 ms, 6.0 ms longCSS: task at 17 ms, 13 ms long
0 msblocking, 0 long tasks
Vanilla JS
Vanilla JS: task at 7.1 ms, 7.3 ms longVanilla JS: task at 22 ms, 13 ms long
0 msblocking, 0 long tasks
Slick
Slick: task at 6.2 ms, 5.8 ms longSlick: task at 20 ms, 7.9 ms longSlick: task at 29 ms, 4.7 ms longSlick: task at 35 ms, 30 ms long
0 msblocking, 0 long tasks
ms
See the numbers
Carousel, Laptop. Tasks of 4 ms or more from one typical run; totals are medians of 15 runs.
VersionStarts atLastsLong task
CSS0 ms blocking (median)0 ms script (median)0 long (median)
CSS task7.3 ms6.0 ms
CSS task17 ms13 ms
Vanilla JS0 ms blocking (median)1.1 ms script (median)0 long (median)
Vanilla JS task7.1 ms7.3 ms
Vanilla JS task22 ms13 ms
Slick0 ms blocking (median)36 ms script (median)0 long (median)
Slick task6.2 ms5.8 ms
Slick task20 ms7.9 ms
Slick task29 ms4.7 ms
Slick task35 ms30 ms

Main thread taskPart past 50 ms: a long task

CSS
CSS: task at 177 ms, 25 ms longCSS: task at 390 ms, 54 ms long, 4.0 ms past 50 ms (a long task)CSS: task at 3,529 ms, 6.5 ms longCSS: task at 3,536 ms, 6.4 ms long
0 mstied bestblocking, 1 long task
Vanilla JS
Vanilla JS: task at 176 ms, 42 ms longVanilla JS: task at 408 ms, 58 ms long, 7.5 ms past 50 ms (a long task)Vanilla JS: task at 469 ms, 8.5 ms longVanilla JS: task at 3,493 ms, 5.9 ms longVanilla JS: task at 3,499 ms, 7.7 ms long
0 mstied bestblocking, 1 long task
Slick
Slick: task at 189 ms, 39 ms longSlick: task at 235 ms, 4.3 ms longSlick: task at 414 ms, 33 ms longSlick: task at 627 ms, 39 ms longSlick: task at 667 ms, 7.1 ms longSlick: task at 676 ms, 5.1 ms longSlick: task at 682 ms, 184 ms long, 134 ms past 50 ms (a long task)Slick: task at 866 ms, 6.5 ms longSlick: task at 956 ms, 4.7 ms longSlick: task at 3,748 ms, 5.2 ms longSlick: task at 3,754 ms, 7.3 ms long
134 msblocking, 1 long task
ms
See the numbers
Carousel, Phone, 4x slower. Tasks of 4 ms or more from one typical run; totals are medians of 15 runs.
VersionStarts atLastsLong task
CSS0 ms blocking (median)0 ms script (median)1 long (median)
CSS task177 ms25 ms
CSS task390 ms54 ms4.0 ms past 50 ms
CSS task3,529 ms6.5 ms
CSS task3,536 ms6.4 ms
Vanilla JS0 ms blocking (median)4.2 ms script (median)1 long (median)
Vanilla JS task176 ms42 ms
Vanilla JS task408 ms58 ms7.5 ms past 50 ms
Vanilla JS task469 ms8.5 ms
Vanilla JS task3,493 ms5.9 ms
Vanilla JS task3,499 ms7.7 ms
Slick134 ms blocking (median)232 ms script (median)1 long (median)
Slick task189 ms39 ms
Slick task235 ms4.3 ms
Slick task414 ms33 ms
Slick task627 ms39 ms
Slick task667 ms7.1 ms
Slick task676 ms5.1 ms
Slick task682 ms184 ms134 ms past 50 ms
Slick task866 ms6.5 ms
Slick task956 ms4.7 ms
Slick task3,748 ms5.2 ms
Slick task3,754 ms7.3 ms

Main thread taskPart past 50 ms: a long task

CSS
CSS: task at 9.3 ms, 8.6 ms longCSS: task at 22 ms, 18 ms longCSS: task at 118 ms, 51 ms long, 0.5 ms past 50 ms (a long task)CSS: task at 229 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 329 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 426 ms, 50 ms longCSS: task at 528 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 626 ms, 50 ms longCSS: task at 728 ms, 50 ms longCSS: task at 824 ms, 50 ms longCSS: task at 926 ms, 50 ms longCSS: task at 1,025 ms, 50 ms longCSS: task at 1,124 ms, 50 ms longCSS: task at 1,224 ms, 50 ms longCSS: task at 1,319 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 1,430 ms, 50 ms longCSS: task at 1,527 ms, 50 ms long, 0.1 ms past 50 ms (a long task)
1.1 msblocking, 6 long tasks
Vanilla JS
Vanilla JS: task at 7.2 ms, 5.7 ms longVanilla JS: task at 20 ms, 10 ms longVanilla JS: task at 114 ms, 50 ms long, 0.3 ms past 50 ms (a long task)Vanilla JS: task at 227 ms, 50 ms longVanilla JS: task at 313 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 422 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 522 ms, 50 ms longVanilla JS: task at 619 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 723 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 822 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 923 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,019 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,125 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,223 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,326 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,419 ms, 50 ms longVanilla JS: task at 1,523 ms, 50 ms long
1.2 msblocking, 11 long tasks
Slick
Slick: task at 5.6 ms, 5.3 ms longSlick: task at 18 ms, 7.1 ms longSlick: task at 26 ms, 4.3 ms longSlick: task at 33 ms, 29 ms longSlick: task at 112 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Slick: task at 217 ms, 50 ms longSlick: task at 316 ms, 50 ms longSlick: task at 412 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Slick: task at 513 ms, 50 ms longSlick: task at 624 ms, 50 ms long, 0.2 ms past 50 ms (a long task)Slick: task at 715 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Slick: task at 813 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Slick: task at 911 ms, 50 ms longSlick: task at 1,012 ms, 50 ms longSlick: task at 1,121 ms, 50 ms longSlick: task at 1,216 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Slick: task at 1,313 ms, 50 ms longSlick: task at 1,415 ms, 50 ms longSlick: task at 1,513 ms, 50 ms longSlick: task at 1,614 ms, 50 ms long, 0.1 ms past 50 ms (a long task)
1.0 msblocking, 7 long tasks
ms
See the numbers
Carousel, Busy page. Tasks of 4 ms or more from one typical run; totals are medians of 15 runs.
VersionStarts atLastsLong task
CSS1.1 ms blocking (median)0 ms script (median)13 long (median)
CSS task9.3 ms8.6 ms
CSS task22 ms18 ms
CSS task118 ms51 ms0.5 ms past 50 ms
CSS task229 ms50 ms0.1 ms past 50 ms
CSS task329 ms50 ms0.1 ms past 50 ms
CSS task426 ms50 ms
CSS task528 ms50 ms0.1 ms past 50 ms
CSS task626 ms50 ms
CSS task728 ms50 ms
CSS task824 ms50 ms
CSS task926 ms50 ms
CSS task1,025 ms50 ms
CSS task1,124 ms50 ms
CSS task1,224 ms50 ms
CSS task1,319 ms50 ms0.1 ms past 50 ms
CSS task1,430 ms50 ms
CSS task1,527 ms50 ms0.1 ms past 50 ms
Vanilla JS1.2 ms blocking (median)1.2 ms script (median)14 long (median)
Vanilla JS task7.2 ms5.7 ms
Vanilla JS task20 ms10 ms
Vanilla JS task114 ms50 ms0.3 ms past 50 ms
Vanilla JS task227 ms50 ms
Vanilla JS task313 ms50 ms0.1 ms past 50 ms
Vanilla JS task422 ms50 ms0.1 ms past 50 ms
Vanilla JS task522 ms50 ms
Vanilla JS task619 ms50 ms0.1 ms past 50 ms
Vanilla JS task723 ms50 ms0.1 ms past 50 ms
Vanilla JS task822 ms50 ms0.1 ms past 50 ms
Vanilla JS task923 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,019 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,125 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,223 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,326 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,419 ms50 ms
Vanilla JS task1,523 ms50 ms
Slick1.0 ms blocking (median)35 ms script (median)13 long (median)
Slick task5.6 ms5.3 ms
Slick task18 ms7.1 ms
Slick task26 ms4.3 ms
Slick task33 ms29 ms
Slick task112 ms50 ms0.1 ms past 50 ms
Slick task217 ms50 ms
Slick task316 ms50 ms
Slick task412 ms50 ms0.1 ms past 50 ms
Slick task513 ms50 ms
Slick task624 ms50 ms0.2 ms past 50 ms
Slick task715 ms50 ms0.1 ms past 50 ms
Slick task813 ms50 ms0.1 ms past 50 ms
Slick task911 ms50 ms
Slick task1,012 ms50 ms
Slick task1,121 ms50 ms
Slick task1,216 ms50 ms0.1 ms past 50 ms
Slick task1,313 ms50 ms
Slick task1,415 ms50 ms
Slick task1,513 ms50 ms
Slick task1,614 ms50 ms0.1 ms past 50 ms

Shows on screen after a click

Shows after a clickSlick winsSlick winsTie with Slick

Every run is a dot. The line marks the median.

One runMedian

CSS
CSS, run 7: shown 32 ms after the clickCSS, run 6: shown 33 ms after the clickCSS, run 11: shown 35 ms after the clickCSS, run 13: shown 37 ms after the clickCSS, run 15: shown 40 ms after the clickCSS, run 3: shown 40 ms after the clickCSS, run 12: shown 41 ms after the clickCSS, run 5: shown 42 ms after the clickCSS, run 10: shown 42 ms after the clickCSS, run 2: shown 42 ms after the clickCSS, run 14: shown 42 ms after the clickCSS, run 8: shown 43 ms after the clickCSS, run 9: shown 43 ms after the clickCSS, run 1: shown 44 ms after the clickCSS, run 4: shown 50 ms after the click
42 msmedian
Vanilla JS
Vanilla JS, run 15: shown 17 ms after the clickVanilla JS, run 4: shown 18 ms after the clickVanilla JS, run 6: shown 22 ms after the clickVanilla JS, run 11: shown 22 ms after the clickVanilla JS, run 13: shown 22 ms after the clickVanilla JS, run 14: shown 24 ms after the clickVanilla JS, run 3: shown 24 ms after the clickVanilla JS, run 12: shown 24 ms after the clickVanilla JS, run 8: shown 24 ms after the clickVanilla JS, run 2: shown 24 ms after the clickVanilla JS, run 7: shown 25 ms after the clickVanilla JS, run 10: shown 25 ms after the clickVanilla JS, run 5: shown 25 ms after the clickVanilla JS, run 1: shown 27 ms after the clickVanilla JS, run 9: shown 28 ms after the click
24 mstied bestmedian
Slick
Slick, run 6: shown 13 ms after the clickSlick, run 15: shown 14 ms after the clickSlick, run 5: shown 15 ms after the clickSlick, run 4: shown 16 ms after the clickSlick, run 3: shown 17 ms after the clickSlick, run 13: shown 17 ms after the clickSlick, run 14: shown 22 ms after the clickSlick, run 12: shown 23 ms after the clickSlick, run 11: shown 23 ms after the clickSlick, run 7: shown 24 ms after the clickSlick, run 2: shown 24 ms after the clickSlick, run 10: shown 26 ms after the clickSlick, run 1: shown 26 ms after the clickSlick, run 9: shown 26 ms after the clickSlick, run 8: shown 27 ms after the click
23 mstied bestmedian
ms after the click
See the numbers
Carousel, Laptop. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS42 ms39 ms to 43 ms44, 42, 40, 50, 42, 33, 32, 43, 43, 42, 35, 41, 37, 42, 40
Vanilla JS24 ms22 ms to 25 ms27, 24, 24, 18, 25, 22, 25, 24, 28, 25, 22, 24, 22, 24, 17
Slick23 ms16 ms to 25 ms26, 24, 17, 16, 15, 13, 24, 27, 26, 26, 23, 23, 17, 22, 14

One runMedian

CSS
CSS, run 13: shown 40 ms after the clickCSS, run 14: shown 40 ms after the clickCSS, run 9: shown 45 ms after the clickCSS, run 1: shown 47 ms after the clickCSS, run 10: shown 47 ms after the clickCSS, run 7: shown 51 ms after the clickCSS, run 6: shown 52 ms after the clickCSS, run 3: shown 55 ms after the clickCSS, run 4: shown 55 ms after the clickCSS, run 2: shown 56 ms after the clickCSS, run 15: shown 58 ms after the clickCSS, run 12: shown 58 ms after the clickCSS, run 5: shown 60 ms after the clickCSS, run 8: shown 62 ms after the clickCSS, run 11: shown 64 ms after the click
55 msmedian
Vanilla JS
Vanilla JS, run 8: shown 23 ms after the clickVanilla JS, run 7: shown 29 ms after the clickVanilla JS, run 11: shown 31 ms after the clickVanilla JS, run 12: shown 33 ms after the clickVanilla JS, run 13: shown 34 ms after the clickVanilla JS, run 15: shown 35 ms after the clickVanilla JS, run 5: shown 39 ms after the clickVanilla JS, run 4: shown 39 ms after the clickVanilla JS, run 9: shown 40 ms after the clickVanilla JS, run 1: shown 40 ms after the clickVanilla JS, run 2: shown 42 ms after the clickVanilla JS, run 6: shown 46 ms after the clickVanilla JS, run 10: shown 48 ms after the clickVanilla JS, run 3: shown 49 ms after the clickVanilla JS, run 14: shown 50 ms after the click
39 mstied bestmedian
Slick
Slick, run 11: shown 30 ms after the clickSlick, run 14: shown 32 ms after the clickSlick, run 10: shown 33 ms after the clickSlick, run 8: shown 36 ms after the clickSlick, run 4: shown 37 ms after the clickSlick, run 15: shown 37 ms after the clickSlick, run 9: shown 38 ms after the clickSlick, run 2: shown 38 ms after the clickSlick, run 12: shown 42 ms after the clickSlick, run 5: shown 42 ms after the clickSlick, run 13: shown 42 ms after the clickSlick, run 6: shown 43 ms after the clickSlick, run 1: shown 50 ms after the clickSlick, run 3: shown 50 ms after the clickSlick, run 7: shown 84 ms after the click
38 mstied bestmedian
ms after the click
See the numbers
Carousel, Phone, 4x slower. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS55 ms47 ms to 58 ms47, 56, 55, 55, 60, 52, 51, 62, 45, 47, 64, 58, 40, 40, 58
Vanilla JS39 ms33 ms to 44 ms40, 42, 49, 39, 39, 46, 29, 23, 40, 48, 31, 33, 34, 50, 35
Slick38 ms37 ms to 43 ms50, 38, 50, 37, 42, 43, 84, 36, 38, 33, 30, 42, 42, 32, 37

One runMedian

CSS
CSS, run 9: shown 28 ms after the clickCSS, run 7: shown 30 ms after the clickCSS, run 3: shown 33 ms after the clickCSS, run 2: shown 36 ms after the clickCSS, run 12: shown 39 ms after the clickCSS, run 13: shown 40 ms after the clickCSS, run 11: shown 43 ms after the clickCSS, run 15: shown 84 ms after the clickCSS, run 14: shown 89 ms after the clickCSS, run 1: shown 90 ms after the clickCSS, run 5: shown 91 ms after the clickCSS, run 4: shown 91 ms after the clickCSS, run 6: shown 91 ms after the clickCSS, run 10: shown 93 ms after the clickCSS, run 8: shown 94 ms after the click
84 msmedian
Vanilla JS
Vanilla JS, run 4: shown 15 ms after the clickVanilla JS, run 3: shown 17 ms after the clickVanilla JS, run 10: shown 33 ms after the clickVanilla JS, run 9: shown 61 ms after the clickVanilla JS, run 7: shown 64 ms after the clickVanilla JS, run 5: shown 67 ms after the clickVanilla JS, run 12: shown 69 ms after the clickVanilla JS, run 6: shown 69 ms after the clickVanilla JS, run 2: shown 73 ms after the clickVanilla JS, run 15: shown 73 ms after the clickVanilla JS, run 13: shown 73 ms after the clickVanilla JS, run 11: shown 74 ms after the clickVanilla JS, run 8: shown 74 ms after the clickVanilla JS, run 14: shown 78 ms after the clickVanilla JS, run 1: shown 79 ms after the click
69 msmedian
Slick
Slick, run 7: shown 13 ms after the clickSlick, run 2: shown 19 ms after the clickSlick, run 4: shown 20 ms after the clickSlick, run 14: shown 22 ms after the clickSlick, run 15: shown 24 ms after the clickSlick, run 11: shown 25 ms after the clickSlick, run 9: shown 27 ms after the clickSlick, run 5: shown 68 ms after the clickSlick, run 3: shown 69 ms after the clickSlick, run 13: shown 71 ms after the clickSlick, run 6: shown 73 ms after the clickSlick, run 10: shown 73 ms after the clickSlick, run 1: shown 75 ms after the clickSlick, run 12: shown 75 ms after the clickSlick, run 8: shown 76 ms after the click
68 msmedian
ms after the click
See the numbers
Carousel, Busy page. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS84 ms37 ms to 91 ms90, 36, 33, 91, 91, 91, 30, 94, 28, 93, 43, 39, 40, 89, 84
Vanilla JS69 ms62 ms to 74 ms79, 73, 17, 15, 67, 69, 64, 74, 61, 33, 74, 69, 73, 78, 73
Slick68 ms23 ms to 73 ms75, 19, 69, 20, 68, 73, 13, 76, 27, 73, 25, 75, 71, 22, 24

Smoothness while it moves

Frames that changedTie with Vanilla JSTie with Vanilla JSTie with Vanilla JS

One typical run, from its first changed frame. A short tick marks a frame where the picture stayed the same.

Frame that changed the pictureFrame painted, picture stillLongest still stretch

CSS
CSS: 22 painted frames over 350 ms, 22 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 43 ms after the click.
100% changed17 ms longest still
Vanilla JS
Vanilla JS: 32 painted frames over 517 ms, 32 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 24 ms after the click.
100% changed17 ms longest still
Slick
Slick: 31 painted frames over 500 ms, 31 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 27 ms after the click.
100% changed17 ms longest still
ms after it starts moving
See the numbers
Carousel, Laptop. Share changed, longest still and pictures are medians of 15 runs; the frame list is one typical run.
VersionFrames that changedLongest stillPicturesThis run started moving atIts frames (ms after it started)
CSS100%17 ms2243 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350
Vanilla JS100%17 ms3224 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500, 517
Slick100%17 ms3127 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500

Frame that changed the pictureFrame painted, picture stillLongest still stretch

CSS
CSS: 18 painted frames over 283 ms, 18 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 62 ms after the click.
100% changed17 ms longest still
Vanilla JS
Vanilla JS: 32 painted frames over 517 ms, 32 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 23 ms after the click.
100% changed17 ms longest still
Slick
Slick: 31 painted frames over 500 ms, 31 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 36 ms after the click.
100% changed17 ms longest still
ms after it starts moving
See the numbers
Carousel, Phone, 4x slower. Share changed, longest still and pictures are medians of 15 runs; the frame list is one typical run.
VersionFrames that changedLongest stillPicturesThis run started moving atIts frames (ms after it started)
CSS100%17 ms1862 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283
Vanilla JS100%17 ms3223 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500, 517
Slick100%17 ms3136 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500

Frame that changed the pictureFrame painted, picture stillLongest still stretch

CSS
CSS: 22 painted frames over 350 ms, 22 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 40 ms after the click.
100% changed17 ms longest still
Vanilla JS
Vanilla JS: 32 painted frames over 517 ms, 32 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 33 ms after the click.
100% changed17 ms longest still
Slick
Slick: 31 painted frames over 500 ms, 31 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 76 ms after the click.
100% changed17 ms longest still
ms after it starts moving
See the numbers
Carousel, Busy page. Share changed, longest still and pictures are medians of 15 runs; the frame list is one typical run.
VersionFrames that changedLongest stillPicturesThis run started moving atIts frames (ms after it started)
CSS100%17 ms2240 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350
Vanilla JS100%17 ms3233 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500, 517
Slick100%17 ms3176 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400, 417, 433, 450, 467, 483, 500

Measure by measure

  • Against Slick: CSS wins 6 of 11, ties 4, loses 1.
  • Against Vanilla JS: CSS wins 4 of 11, ties 6, loses 1.

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieJavaScript ahead, the same steps

Tie: the middle half of runs overlap, or the medians sit under 16.7 ms apart (one frame at 60 frames a second). Bytes and lines compare exactly. While both layout shift scores are under 0.1 (Google's line for good), the winner is slightly ahead at most.

Carousel, Laptop: CSS against each JavaScript version
MeasureCSS against SlickCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS2.2 KBSlick44.3 KBCSS aheadCSS2.2 KBVanilla JS3.9 KB
JavaScript downloadedCSS far aheadCSS0 KBSlick38.1 KBCSS far aheadCSS0 KBVanilla JS1.8 KB
Script time while loadingCSS far aheadCSS0 msSlick36 msTieCSS0 msVanilla JS1.1 ms
Blocking timeTieCSS0 msSlick0 msTieCSS0 msVanilla JS0 ms
Time until it worksCSS aheadCSS36 msSlick69 msTieCSS36 msVanilla JS37 ms
Layout shift while loadingTieCSS0Slick0TieCSS0Vanilla JS0
Shows after a clickSlick aheadCSS42 msSlick23 msVanilla JS aheadCSS42 msVanilla JS24 ms
Click responseTieCSS9.3 msSlick4.7 msTieCSS9.3 msVanilla JS3.9 ms
Frames that changedTieCSS100%Slick100%TieCSS100%Vanilla JS100%
Works with JavaScript offCSS far aheadCSSworksSlickshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS153 linesSlick10,431 linesCSS aheadCSS153 linesVanilla JS253 lines
  • Against Slick: CSS wins 7 of 11, ties 3, loses 1.
  • Against Vanilla JS: CSS wins 4 of 11, ties 7, loses 0.

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieJavaScript ahead, the same steps

Tie: the middle half of runs overlap, or the medians sit under 16.7 ms apart (one frame at 60 frames a second). Bytes and lines compare exactly. While both layout shift scores are under 0.1 (Google's line for good), the winner is slightly ahead at most.

Carousel, Phone, 4x slower: CSS against each JavaScript version
MeasureCSS against SlickCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS2.2 KBSlick44.3 KBCSS aheadCSS2.2 KBVanilla JS3.9 KB
JavaScript downloadedCSS far aheadCSS0 KBSlick38.1 KBCSS far aheadCSS0 KBVanilla JS1.8 KB
Script time while loadingCSS far aheadCSS0 msSlick232 msTieCSS0 msVanilla JS4.2 ms
Blocking timeCSS far aheadCSS0 msSlick134 msTieCSS0 msVanilla JS0 ms
Time until it worksCSS aheadCSS474 msSlick862 msTieCSS474 msVanilla JS466 ms
Layout shift while loadingTieCSS0Slick0TieCSS0Vanilla JS0
Shows after a clickSlick slightly aheadCSS55 msSlick38 msTieCSS55 msVanilla JS39 ms
Click responseTieCSS12 msSlick20 msTieCSS12 msVanilla JS13 ms
Frames that changedTieCSS100%Slick100%TieCSS100%Vanilla JS100%
Works with JavaScript offCSS far aheadCSSworksSlickshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS153 linesSlick10,431 linesCSS aheadCSS153 linesVanilla JS253 lines
  • Against Slick: CSS wins 6 of 11, ties 5, loses 0.
  • Against Vanilla JS: CSS wins 4 of 11, ties 7, loses 0.

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieJavaScript ahead, the same steps

Tie: the middle half of runs overlap, or the medians sit under 16.7 ms apart (one frame at 60 frames a second). Bytes and lines compare exactly. While both layout shift scores are under 0.1 (Google's line for good), the winner is slightly ahead at most.

Carousel, Busy page: CSS against each JavaScript version
MeasureCSS against SlickCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS2.2 KBSlick44.3 KBCSS aheadCSS2.2 KBVanilla JS3.9 KB
JavaScript downloadedCSS far aheadCSS0 KBSlick38.1 KBCSS far aheadCSS0 KBVanilla JS1.8 KB
Script time while loadingCSS far aheadCSS0 msSlick35 msTieCSS0 msVanilla JS1.2 ms
Blocking timeTieCSS1.1 msSlick1.0 msTieCSS1.1 msVanilla JS1.2 ms
Time until it worksCSS aheadCSS33 msSlick70 msTieCSS33 msVanilla JS34 ms
Layout shift while loadingTieCSS0Slick0TieCSS0Vanilla JS0
Shows after a clickTieCSS84 msSlick68 msTieCSS84 msVanilla JS69 ms
Click responseTieCSS3.1 msSlick4.5 msTieCSS3.1 msVanilla JS3.3 ms
Frames that changedTieCSS100%Slick100%TieCSS100%Vanilla JS100%
Works with JavaScript offCSS far aheadCSSworksSlickshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS153 linesSlick10,431 linesCSS aheadCSS153 linesVanilla JS253 lines

The code

Writing the Slick version takes fewer lines: 125 against 153 for CSS. Count Slick's library code and the total reverses: 10,431 for Slick, 153 for CSS.

Lines of code

Lines of codeCSS wins

What you write, plus the library code the page loads, counted from the library's readable source.

You writeThe library bringsIn each version's color

CSS
CSS: 153 lines, 153 you write
153 linesbest153 you writeno library
Vanilla JS
Vanilla JS: 253 lines, 253 you write
253 lines253 you writeno library
Slick
Slick: 10,431 lines, 125 you write, 10,306 the library brings
10,431 lines125 you write10,306 library
lines
See the numbers
Carousel, lines of code: each version's own files, plus the library code its page loads, counted from the library's readable (unminified) source. Blank lines skipped.
FileKindLines
CSS: carousel.cssYou write, CSS131
CSS: index.htmlYou write, HTML22
CSS total153 you write, 0 from the library153
Vanilla JS: carousel.cssYou write, CSS120
Vanilla JS: carousel.jsYou write, JavaScript99
Vanilla JS: index.htmlYou write, HTML34
Vanilla JS total253 you write, 0 from the library253
Slick: carousel.cssYou write, CSS89
Slick: index.htmlYou write, HTML27
Slick: init.jsYou write, JavaScript9
Slick: slick-carousel/slick/slick.cssLibrary, CSS84
Slick: slick-carousel/slick/slick-theme.cssLibrary, CSS144
Slick: jquery/dist/jquery.jsLibrary, JavaScript7,877
Slick: slick-carousel/slick/slick.jsLibrary, JavaScript2,201
Slick total125 you write, 10,306 from the library10,431
The Slick version125 lines in 3 files

index.html27 lines

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Carousel: Slick 2.0.0</title>
<link rel="stylesheet" href="/vendor/slick-carousel/slick/slick.css">
<link rel="stylesheet" href="/vendor/slick-carousel/slick/slick-theme.css">
<link rel="stylesheet" href="carousel.css">
</head>
<body>
<div class="demo-scroll-carousel">
	<div class="carousel-wrap">
		<div class="carousel">
			<div class="carousel-slide">Slide 1 of 5</div>
			<div class="carousel-slide">Slide 2 of 5</div>
			<div class="carousel-slide">Slide 3 of 5</div>
			<div class="carousel-slide">Slide 4 of 5</div>
			<div class="carousel-slide">Slide 5 of 5</div>
		</div>
	</div>
</div>
<script src="/vendor/jquery/dist/jquery.min.js"></script>
<script src="/vendor/slick-carousel/slick/slick.min.js"></script>
<script src="init.js"></script>
</body>
</html>

carousel.css89 lines

/*
 * Carousel, library version: Slick 2.0.0 with its own slick.css and slick-theme.css.
 * This file only styles. It gives the slides their size and colors, and moves the theme's
 * arrows and dots to where the other two versions draw theirs (the theme puts white arrows
 * outside the slider, where they vanish on a light page). Nothing here changes how Slick behaves.
 */

.demo-scroll-carousel .carousel-wrap {
	position: relative;
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
	/* Slick writes pixel widths on its slides and track. Inside a grid or flex item (the page
	   shell is a grid) those widths push the column wider than a phone screen, so the wrap
	   keeps its content out of its parent's sizing */
	contain: inline-size;
}

.demo-scroll-carousel .slick-list {
	border-radius: 10px;
}

.demo-scroll-carousel .carousel-slide {
	/* Slick's default rows: 1 wraps each slide in two divs and sets an inline
	   display: inline-block on it, so centering the text needs !important */
	display: flex !important;
	height: 160px;
	align-items: center;
	justify-content: center;
	font-size: 1.2rem;
	font-weight: 700;
	color: #0c0c0d;
	-webkit-user-select: none;
	user-select: none;
}

/* after the wrapping, the slides are counted on Slick's outer .slick-slide boxes */
.demo-scroll-carousel .slick-slide:nth-child(1) .carousel-slide { background: #c084fc; }
.demo-scroll-carousel .slick-slide:nth-child(2) .carousel-slide { background: #38bdf8; }
.demo-scroll-carousel .slick-slide:nth-child(3) .carousel-slide { background: #ffd444; }
.demo-scroll-carousel .slick-slide:nth-child(4) .carousel-slide { background: #57d9a3; }
.demo-scroll-carousel .slick-slide:nth-child(5) .carousel-slide { background: #b8ff57; }

/* Arrows: the theme's icon font glyphs, on a dark circle inside the slide's edges */
.demo-scroll-carousel .slick-arrow,
.demo-scroll-carousel .slick-arrow:hover,
.demo-scroll-carousel .slick-arrow:focus {
	z-index: 1;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(24, 22, 29, .6);
}

.demo-scroll-carousel .slick-prev {
	left: 8px;
}

.demo-scroll-carousel .slick-next {
	right: 8px;
}

.demo-scroll-carousel .slick-arrow:before {
	font-size: 16px;
	opacity: 1;
}

/* Slick marks the arrow at each end with .slick-disabled and aria-disabled */
.demo-scroll-carousel .slick-arrow.slick-disabled {
	opacity: .35;
	cursor: default;
}

.demo-scroll-carousel .slick-arrow:focus-visible {
	outline: 2px solid #18161d;
	outline-offset: 2px;
}

/* Dots: the theme's 20px boxes 30px apart, drawn as a 10px dot */
.demo-scroll-carousel .slick-dots li button:before {
	content: "";
	top: 5px;
	left: 5px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #18161d;
}

.demo-scroll-carousel .slick-dots li button:focus-visible {
	outline: 2px solid #18161d;
	outline-offset: 1px;
	border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
	/* Slick writes its transition inline on the track, so only !important turns it off */
	.demo-scroll-carousel .slick-track {
		transition: none !important;
		animation: none;
	}
}

init.js9 lines

// Slick 2.0.0, started the way the package's own demo page does it.
// Every other option keeps its default: speed 500 and cssEase 'ease' (slick.js lines 91 and 64).
$(function () {
	$('.carousel').slick({
		arrows: true, // already the default (slick.js line 56), written out for clarity
		dots: true, // default false; the shared behavior has one dot per slide
		infinite: false // default true, which loops; the shared behavior stops at both ends
	});
});
Slick 2.0.0: the library files it loads, gzipped
FileKindSize
slick.cssCSS0.5 KB
slick-theme.cssCSS0.8 KB
jquery.min.jsJavaScript27.5 KB
slick.min.jsJavaScript10.2 KB
ajax-loader.gifImage2.6 KB
slick.woff2Image or font0.8 KB
Total42.5 KB
The vanilla JavaScript version253 lines in 3 files

This version holds the slide move at 500 ms to match Slick. It listens for pointerdown, pointermove, pointerup and pointercancel to follow a mouse drag, and supports arrow, Home and End keys.

index.html34 lines

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Carousel: vanilla JavaScript</title>
<link rel="stylesheet" href="carousel.css">
<script src="carousel.js" defer></script>
</head>
<body>
<div class="demo-scroll-carousel">
	<div class="carousel-wrap" role="region" aria-roledescription="carousel" aria-label="Slides">
		<div class="carousel" aria-live="polite">
			<div class="carousel-track">
				<div class="carousel-slide" id="carousel-slide-1" role="tabpanel" aria-roledescription="slide" aria-label="1 of 5">Slide 1 of 5</div>
				<div class="carousel-slide" id="carousel-slide-2" role="tabpanel" aria-roledescription="slide" aria-label="2 of 5">Slide 2 of 5</div>
				<div class="carousel-slide" id="carousel-slide-3" role="tabpanel" aria-roledescription="slide" aria-label="3 of 5">Slide 3 of 5</div>
				<div class="carousel-slide" id="carousel-slide-4" role="tabpanel" aria-roledescription="slide" aria-label="4 of 5">Slide 4 of 5</div>
				<div class="carousel-slide" id="carousel-slide-5" role="tabpanel" aria-roledescription="slide" aria-label="5 of 5">Slide 5 of 5</div>
			</div>
		</div>
		<button class="carousel-arrow carousel-prev" type="button" aria-label="Previous slide"></button>
		<button class="carousel-arrow carousel-next" type="button" aria-label="Next slide"></button>
		<div class="carousel-dots" role="tablist" aria-label="Choose a slide">
			<button class="carousel-dot" type="button" role="tab" aria-controls="carousel-slide-1" aria-label="Slide 1"></button>
			<button class="carousel-dot" type="button" role="tab" aria-controls="carousel-slide-2" aria-label="Slide 2"></button>
			<button class="carousel-dot" type="button" role="tab" aria-controls="carousel-slide-3" aria-label="Slide 3"></button>
			<button class="carousel-dot" type="button" role="tab" aria-controls="carousel-slide-4" aria-label="Slide 4"></button>
			<button class="carousel-dot" type="button" role="tab" aria-controls="carousel-slide-5" aria-label="Slide 5"></button>
		</div>
	</div>
</div>
</body>
</html>

carousel.css120 lines

/*
 * Carousel, vanilla JavaScript version: a track moved with transform and a CSS transition.
 * The transition is Slick 2.0.0's default, speed 500 with cssEase 'ease' (slick.js lines 91
 * and 64), so the library runs untuned and this version matches it.
 * Icons: Font Awesome Free 7.3.1 arrow-left and arrow-right, CC BY 4.0,
 * https://fontawesome.com/license/free
 */

/* The arrows are placed against the wrap, so it is the positioned box */
.demo-scroll-carousel .carousel-wrap {
	position: relative;
	width: 100%;
	max-width: 520px;
	margin: 0 auto;
}

/* the frame that clips the track to one slide */
.demo-scroll-carousel .carousel {
	overflow: hidden;
	/* clip, where supported, cannot be scrolled, so focusing a slide never shifts the frame */
	overflow: clip;
	border-radius: 10px;
	/* vertical swipes still scroll the page; horizontal ones go to the script */
	touch-action: pan-y;
	cursor: grab;
}

.demo-scroll-carousel .carousel-wrap.is-dragging .carousel {
	cursor: grabbing;
}

.demo-scroll-carousel .carousel-track {
	display: flex;
	transition: transform 500ms ease;
}

/* the track follows the pointer while it is held */
.demo-scroll-carousel .carousel-wrap.is-dragging .carousel-track {
	transition: none;
}

.demo-scroll-carousel .carousel-slide {
	flex: 0 0 100%;
	height: 160px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.2rem;
	font-weight: 700;
	color: #0c0c0d;
	-webkit-user-select: none;
	user-select: none;
}

.demo-scroll-carousel .carousel-slide:nth-child(1) { background: #c084fc; }
.demo-scroll-carousel .carousel-slide:nth-child(2) { background: #38bdf8; }
.demo-scroll-carousel .carousel-slide:nth-child(3) { background: #ffd444; }
.demo-scroll-carousel .carousel-slide:nth-child(4) { background: #57d9a3; }
.demo-scroll-carousel .carousel-slide:nth-child(5) { background: #b8ff57; }

.demo-scroll-carousel .carousel-slide:focus-visible {
	outline: 2px solid #18161d;
	outline-offset: -4px;
}

/* Arrows */
.demo-scroll-carousel .carousel-arrow {
	position: absolute;
	/* half the slide height, so the arrow sits on the slide's middle */
	top: 80px;
	width: 40px;
	height: 40px;
	margin-top: -20px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: rgba(24, 22, 29, .6);
	background-position: center;
	background-size: 16px 16px;
	background-repeat: no-repeat;
	cursor: pointer;
}

.demo-scroll-carousel .carousel-prev {
	left: 8px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23fff' d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288 480 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-370.7 0 105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z'/%3E%3C/svg%3E");
}

.demo-scroll-carousel .carousel-next {
	right: 8px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23fff' d='M502.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l370.7 0-105.4 105.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z'/%3E%3C/svg%3E");
}

/* aria-disabled rather than disabled, so a focused arrow keeps focus at the last slide */
.demo-scroll-carousel .carousel-arrow[aria-disabled="true"] {
	opacity: .35;
	cursor: default;
}

.demo-scroll-carousel .carousel-arrow:focus-visible {
	outline: 2px solid #18161d;
	outline-offset: 2px;
}

/* Dots: one per slide, in a 20px box with a 10px dot inside */
.demo-scroll-carousel .carousel-dots {
	display: flex;
	justify-content: center;
	gap: 10px;
	height: 20px;
	margin: 5px 0;
}

.demo-scroll-carousel .carousel-dot {
	width: 20px;
	height: 20px;
	padding: 0;
	border: 5px solid transparent;
	border-radius: 50%;
	background: rgba(24, 22, 29, .25) padding-box;
	cursor: pointer;
}

.demo-scroll-carousel .carousel-dot[aria-selected="true"] {
	background-color: rgba(24, 22, 29, .75);
}

.demo-scroll-carousel .carousel-dot:focus-visible {
	outline: 2px solid #18161d;
	outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
	.demo-scroll-carousel .carousel-track {
		transition: none;
		animation: none;
	}
}

carousel.js99 lines

// Carousel, vanilla JavaScript version, for the purecss.com test rig.
// The track moves with transform and a CSS transition (500ms ease, Slick 2.0.0's defaults; see
// carousel.css). Swipe and drag follow Slick's defaults too: a fifth of the width advances one
// slide (touchThreshold 5), and pulling past either end moves at 0.35 of the pointer
// (edgeFriction 0.35, slick.js line 72).
(() => {
	const SWIPE_FRACTION = 1 / 5;
	const EDGE_FRICTION = 0.35;

	const root = document.querySelector('.demo-scroll-carousel .carousel-wrap');
	if (!root) return;
	const frame = root.querySelector('.carousel');
	const track = root.querySelector('.carousel-track');
	const slides = Array.from(track.children);
	const prev = root.querySelector('.carousel-prev');
	const next = root.querySelector('.carousel-next');
	const dots = Array.from(root.querySelectorAll('.carousel-dot'));
	const last = slides.length - 1;
	let index = 0;

	function render() {
		// percentages of the track, which is one slide wide, so no measuring and no resize handler
		track.style.transform = index ? `translateX(${-index * 100}%)` : '';
		slides.forEach((slide, i) => {
			const current = i === index;
			slide.setAttribute('aria-hidden', String(!current));
			slide.tabIndex = current ? 0 : -1;
		});
		dots.forEach((dot, i) => {
			const current = i === index;
			dot.setAttribute('aria-selected', String(current));
			dot.tabIndex = current ? 0 : -1;
		});
		prev.setAttribute('aria-disabled', String(index === 0));
		next.setAttribute('aria-disabled', String(index === last));
	}

	// stops at both ends rather than looping
	function goTo(target) {
		index = Math.max(0, Math.min(last, target));
		render();
	}

	prev.addEventListener('click', () => goTo(index - 1));
	next.addEventListener('click', () => goTo(index + 1));
	root.querySelector('.carousel-dots').addEventListener('click', (event) => {
		const i = dots.indexOf(event.target.closest('.carousel-dot'));
		if (i !== -1) goTo(i);
	});

	// Arrow keys from the slide, the arrows or the dots, as in Slick; Home and End as well
	root.addEventListener('keydown', (event) => {
		const keys = { ArrowLeft: index - 1, ArrowRight: index + 1, Home: 0, End: last };
		if (!(event.key in keys) || event.altKey || event.ctrlKey || event.metaKey) return;
		event.preventDefault();
		const focused = document.activeElement;
		goTo(keys[event.key]);
		// focus follows the current slide or dot when it was on one
		if (dots.includes(focused)) dots[index].focus();
		else if (slides.includes(focused)) slides[index].focus({ preventScroll: true });
	});

	// Dragging and swiping, with pointer events: the track follows the pointer, then settles
	let drag = null;
	let pending = 0;

	function paintDrag() {
		pending = 0;
		if (drag) track.style.transform = `translateX(${drag.base + drag.offset}px)`;
	}

	frame.addEventListener('pointerdown', (event) => {
		if (drag || !event.isPrimary || event.button !== 0) return;
		drag = { id: event.pointerId, startX: event.clientX, width: frame.clientWidth, base: 0, offset: 0, moving: false };
		frame.setPointerCapture(event.pointerId);
	}, { passive: true });

	frame.addEventListener('pointermove', (event) => {
		if (!drag || event.pointerId !== drag.id) return;
		const dx = event.clientX - drag.startX;
		if (!drag.moving) {
			if (dx === 0) return;
			// start from where the track is drawn now, even partway through a transition
			drag.base = new DOMMatrixReadOnly(getComputedStyle(track).transform).m41;
			drag.moving = true;
			root.classList.add('is-dragging');
		}
		const pastEdge = (index === 0 && dx > 0) || (index === last && dx < 0);
		drag.offset = pastEdge ? dx * EDGE_FRICTION : dx;
		if (!pending) pending = requestAnimationFrame(paintDrag);
	}, { passive: true });

	function endDrag(event) {
		if (!drag || event.pointerId !== drag.id) return;
		const { moving, startX, width } = drag;
		const dx = event.type === 'pointercancel' ? 0 : event.clientX - startX;
		drag = null;
		if (pending) cancelAnimationFrame(pending);
		pending = 0;
		if (!moving) return;
		root.classList.remove('is-dragging');
		if (Math.abs(dx) >= width * SWIPE_FRACTION) goTo(index + (dx < 0 ? 1 : -1));
		else render();
	}

	frame.addEventListener('pointerup', endDrag, { passive: true });
	// a vertical swipe hands the gesture to the page (touch-action: pan-y), which cancels it here
	frame.addEventListener('pointercancel', endDrag, { passive: true });

	render();
})();

When JavaScript still makes sense

  • You need a settable duration or easing.

    Chrome picks the scroll duration from the distance traveled. Slick holds every move at 500 ms with a settable easing.

  • Mouse drag matters on desktop.

    A mouse drag does nothing in the CSS version. Slick follows it and shows a grab cursor.

  • You want a lower drag threshold.

    A slow touch drag in CSS has to pass halfway before it lands on the next slide. Slick switches at a fifth of the width.

CSS moves with a wheel or trackpad as native scrolling. Slick and vanilla do not. The CSS arrows (::scroll-button(left) and ::scroll-button(right)) and dots (::scroll-marker) need Chrome or Edge 135 and later. Clicking a dot during a move sends CSS to the new slide at once, while Slick drops the click. In CSS the Tab stops are the current dot, the next arrow when one is not disabled, and the scroller, while arrow keys do nothing when an arrow button has focus. Slick has four stops (previous arrow, current slide, next arrow, current dot) and Left and Right work on all four. Dragging past the end makes Slick follow the pointer partway then spring back.

Switching from Slick

  1. Your markup needs .demo-scroll-carousel > .carousel-wrap > .carousel, with your slides as .carousel-slide children of .carousel. Slick builds .slick-list, .slick-track, its arrows and its dots at run time.
  2. Copy the CSS version's carousel.css. The arrows are ::scroll-button(left) and ::scroll-button(right), the dots are ::scroll-marker in a scroll-marker-group, and the scroller has will-change: scroll-position so Chrome does not run the arrow scroll on the main thread.
  3. Delete the .slick() call. Delete slick.min.js (10.2 KB), slick.css (0.5 KB), slick-theme.css (0.8 KB), slick.woff2 (0.8 KB), and ajax-loader.gif (2.6 KB). Delete jquery.min.js (27.5 KB) if nothing else on the page needs it.

Slick settings in HTML and CSS

Slick settingIn HTML and CSS
slidesToShowSet the slide width with flex: 0 0 calc((100% - 2 * 10px) / 3) and gap: 10px on .carousel for three per view. Chrome and Edge build one dot per slide (five dots for five slides), with no dots in Firefox or Safari. Slick builds three dots when looping is turned off. In Chromium the last slide's dot is marked as current at the end.
slidesToScrollscroll-snap-stop: always keeps an arrow click or a quick swipe to one slide. Chrome and Edge only for the arrows.
infiniteNo CSS equivalent for a looping carousel. A scroll container stops at both ends.
dotsscroll-marker-group: after tabs with ::scroll-marker on each slide. Chrome and Edge only.
appendDotsscroll-marker-group: before tabs puts the dots above the slides. Chrome and Edge only.
customPagingPut the number or thumbnail in each slide's ::scroll-marker with content: "1" / "Slide 1" for numbered dots, or a background-image for thumbnails. Chrome and Edge only.
arrows::scroll-button(left) and ::scroll-button(right). Chrome and Edge only. content: none on both removes them.
prevArrow, nextArrowThe arrows can show text glyphs or images, and can sit inside or outside the slide frame by changing their positioning. Chrome and Edge only.
autoplayNo dependable CSS autoplay for this carousel.
speed, cssEaseNo CSS equivalent for a set duration and curve. scroll-behavior: auto makes the arrows and dots jump (Chrome and Edge only for those).
fadeA separate build with radio buttons, the slides stacked in one grid cell, and transition: opacity 500ms ease on each slide so the checked radio's slide fades in. No swipe or wheel, and this build has no arrows.
centerModescroll-snap-align: center on the slides and padding-inline: 50px on the scroller.
variableWidthEach slide gets flex: 0 0 auto with its own width. The last slide cannot reach the start edge.
adaptiveHeightNo CSS equivalent for a carousel whose height follows the current slide. Drop the fixed height and the flex row makes every slide as tall as the tallest.
responsiveA media query for the window width or a container query on the wrap.
draggableNo CSS equivalent for mouse drag.
swipeoverflow-x: hidden on the scroller turns off the wheel, but the arrows still work in Chrome and Edge. For touch swipes off in Chromium, touch-action: pan-y.
verticalscroll-snap-type: y mandatory in a fixed-height column with flex-direction: column. Build up and down arrows with ::scroll-button(up) and ::scroll-button(down), and hide the left and right ones with content: none on both. Chrome and Edge only for the arrows.
lazyLoadloading="lazy" on each <img>. The browser decides how far ahead it loads. Slick fades each image in as it loads, while the HTML attribute has no fade-in.
rtldir="rtl" on the wrap. The physical left and right arrows (Chrome and Edge only) swap jobs but keep their names.

Browser support

FeatureChromeFirefoxSafariEdge
Scroll snap69681179
::scroll-button()135NoNo135
::scroll-marker135NoNo135

The figures come from Can I Use for scroll snap, and MDN's browser compatibility data for ::scroll-button() and ::scroll-marker. In Firefox and Safari the CSS carousel is a swipeable row with no arrows or dots.

Questions

Can I build a carousel slider in CSS instead of Slick?
Scroll snap gets you a swipeable carousel. Add ::scroll-button(left), ::scroll-button(right), ::scroll-marker and scroll-marker-group for the arrows and dots, but those need Chrome or Edge 135 and later.
How much faster is CSS than Slick?
CSS worked sooner on the slow phone test: 474 ms against 862 ms for Slick, after 232 ms of script.
Does a CSS carousel work without JavaScript?
The CSS carousel works without JavaScript. Slick shows its content, but clicks do nothing, and the vanilla version does not work.
How do I make a vertical carousel?
Set scroll-snap-type: y mandatory on the scroller with flex-direction: column and a fixed height.
How do I make an image slider or a carousel of images?
Put an <img> inside each .carousel-slide with display: block, width: 100%, height: 100% and object-fit: cover. Add loading="lazy" to each image so the browser loads them as the carousel moves.
How do I style or change the arrows?
Style the ::scroll-button(left) and ::scroll-button(right) pseudo-elements. The arrows work in Chrome and Edge only.
Scroll Snap CarouselThis technique on its own page, with more ways to build it.