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 Accordion vs CSS

A three-panel accordion in CSS and jQuery UI. CSS runs on the page, jQuery UI in two sandboxed frames. The switch shows one of the two jQuery UI builds: the full library or a trimmed build.

CSS

<details name="faq">

Wins overall8 wins3 ties0 losses

On the laptop test, all 11 measures

Wins overall8 wins3 ties0 losses

On the laptop test, all 11 measures

Wins overall10 wins0 ties1 loss

On the slow phone test, all 11 measures

Wins overall10 wins0 ties1 loss

On the slow phone test, all 11 measures

Wins overall8 wins3 ties0 losses

On the busy page test, all 11 measures

Wins overall7 wins4 ties0 losses

On the busy page test, all 11 measures

Wins1.6 KBdownload size, gzippedWins1.6 KBdownload size, gzipped
What is Pure CSS?
Pure CSS refers to techniques that achieve interactive UI patterns using only CSS, with no JavaScript required.
Which browsers are supported?
All modern browsers support the features used in these examples. Check caniuse.com for specific properties.
Can I use these in production?
Yes! These are real CSS techniques used in production sites. Always consider accessibility requirements for your use case.

jQuery UIjQuery UI, trimmed

jQuery UI 1.14.2jQuery UI 1.14.2, trimmed to the accordion

Loses overall0 wins3 ties8 losses

On the laptop test, all 11 measures

Loses overall0 wins3 ties8 losses

On the laptop test, all 11 measures

Loses overall1 win0 ties10 losses

On the slow phone test, all 11 measures

Loses overall1 win0 ties10 losses

On the slow phone test, all 11 measures

Loses overall0 wins3 ties8 losses

On the busy page test, all 11 measures

Loses overall0 wins4 ties7 losses

On the busy page test, all 11 measures

Which jQuery UI build
Loses124.3 KBdownload size, gzippedLoses46.6 KBdownload size, gzipped

95.7 KB of JavaScript, from jQuery 4.0.0 and jQuery UI 1.14.2.33.6 KB of JavaScript, from jQuery 4.0.0 and jQuery UI 1.14.2 (custom build: core and accordion).

Test condition

Who wins

CSS winsTieCSS loses

  • Against jQuery UI

    CSS wins 8, ties 3, loses 0

    CSS wins: 8 of 11 measures, against jQuery UI, laptop8Tie: 3 of 11 measures, against jQuery UI, laptop3
  • Against jQuery UI, trimmed

    CSS wins 8, ties 3, loses 0

    CSS wins: 8 of 11 measures, against jQuery UI, trimmed, laptop8Tie: 3 of 11 measures, against jQuery UI, trimmed, laptop3
  • Against Vanilla JS

    CSS wins 4, ties 7, loses 0

    CSS wins: 4 of 11 measures, against Vanilla JS, laptop4Tie: 7 of 11 measures, against Vanilla JS, laptop7
  • Against jQuery UI

    CSS wins 10, ties 0, loses 1

    CSS wins: 10 of 11 measures, against jQuery UI, phone, 4x slower10CSS loses: 1 of 11 measures, against jQuery UI, phone, 4x slower1
  • Against jQuery UI, trimmed

    CSS wins 10, ties 0, loses 1

    CSS wins: 10 of 11 measures, against jQuery UI, trimmed, phone, 4x slower10CSS loses: 1 of 11 measures, against jQuery UI, trimmed, 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 jQuery UI

    CSS wins 8, ties 3, loses 0

    CSS wins: 8 of 11 measures, against jQuery UI, busy page8Tie: 3 of 11 measures, against jQuery UI, busy page3
  • Against jQuery UI, trimmed

    CSS wins 7, ties 4, loses 0

    CSS wins: 7 of 11 measures, against jQuery UI, trimmed, busy page7Tie: 4 of 11 measures, against jQuery UI, trimmed, busy page4
  • 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, jQuery UI on the right, one measure per row. Green marks who wins, red who loses, gray a tie. The switch in the jQuery UI lane picks which build sits on the right.

CSS

jQuery UIjQuery UI, trimmed

JavaScript downloadedCSS wins

0 KB95.7 KB

Everything downloadedCSS wins

1.6 KB124.3 KB

Script time while loadingCSS wins

0 ms26 ms

Time until it worksCSS wins

31 ms65 ms

Lines of codeCSS wins

11624,954

With JavaScript offCSS wins

WorksShows, clicks do nothing

JavaScript downloadedCSS wins

0 KB33.6 KB

Everything downloadedCSS wins

1.6 KB46.6 KB

Script time while loadingCSS wins

0 ms21 ms

Time until it worksCSS wins

31 ms57 ms

Lines of codeCSS wins

1169,691

With JavaScript offCSS wins

WorksShows, clicks do nothing

Vanilla JavaScript: 1.7 KB of JavaScript, works at 33 ms, 212 lines to write, does not work with script off.

JavaScript downloadedCSS wins

0 KB95.7 KB

Everything downloadedCSS wins

1.6 KB124.3 KB

Script time while loadingCSS wins

0 ms131 ms

Time until it worksCSS wins

455 ms1,024 ms

Lines of codeCSS wins

11624,954

With JavaScript offCSS wins

WorksShows, clicks do nothing

JavaScript downloadedCSS wins

0 KB33.6 KB

Everything downloadedCSS wins

1.6 KB46.6 KB

Script time while loadingCSS wins

0 ms108 ms

Time until it worksCSS wins

455 ms694 ms

Lines of codeCSS wins

1169,691

With JavaScript offCSS wins

WorksShows, clicks do nothing

Vanilla JavaScript: 1.7 KB of JavaScript, works at 448 ms, 212 lines to write, does not work with script off.

JavaScript downloadedCSS wins

0 KB95.7 KB

Everything downloadedCSS wins

1.6 KB124.3 KB

Script time while loadingCSS wins

0 ms25 ms

Time until it worksCSS wins

29 ms63 ms

Lines of codeCSS wins

11624,954

With JavaScript offCSS wins

WorksShows, clicks do nothing

JavaScript downloadedCSS wins

0 KB33.6 KB

Everything downloadedCSS wins

1.6 KB46.6 KB

Script time while loadingCSS wins

0 ms19 ms

Time until it worksCSS wins

29 ms53 ms

Lines of codeCSS wins

1169,691

With JavaScript offCSS wins

WorksShows, clicks do nothing

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

Laptop: 1280 x 800, no throttling. 15 runs per version in Chrome 157, Nov 19, 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 19, 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 19, 2026.

Replacing a JavaScript accordion

  1. 1Set up the markup

    A second accordion on the same page needs its own name value. Every <details> sharing a name acts as one group.

    index.html25 lines

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Accordion: CSS (details name)</title>
    <link rel="stylesheet" href="accordion.css">
    </head>
    <body>
    <div class="demo-accordion">
    	<details name="faq" open>
    		<summary>What is Pure CSS?</summary>
    		<div class="accordion-body">Pure CSS refers to techniques that achieve interactive UI patterns using only CSS, with no JavaScript required.</div>
    	</details>
    	<details name="faq">
    		<summary>Which browsers are supported?</summary>
    		<div class="accordion-body">All modern browsers support the features used in these examples. Check caniuse.com for specific properties.</div>
    	</details>
    	<details name="faq">
    		<summary>Can I use these in production?</summary>
    		<div class="accordion-body">Yes! These are real CSS techniques used in production sites. Always consider accessibility requirements for your use case.</div>
    	</details>
    </div>
    </body>
    </html>
  2. 2Add the styles

    The CSS animates the panel height with ::details-content and sets the colors and spacing.

    accordion.css91 lines

    /*
     * Accordion, CSS version (purecss.com test rig)
     * <details name="faq"> keeps one panel open at a time. ::details-content
     * animates the panel height from 0 to auto, which interpolate-size allows.
     * Timing matches jQuery UI's default accordion animation: 400ms "swing",
     * drawn here as cubic-bezier(0.37, 0, 0.63, 1).
     */
    
    .demo-accordion {
    	--surface: #ffffff;
    	--border: #d0ccc0;
    	--text: #1a1a1a;
    	--text-muted: #5c5c55;
    	--accent: #6f2fd6;
    	--accent-dim: rgba(111, 47, 214, .08);
    	--duration: 400ms;
    	--easing: cubic-bezier(0.37, 0, 0.63, 1);
    	display: flex;
    	flex-direction: column;
    	align-items: center;
    	color: var(--text);
    	interpolate-size: allow-keywords;
    }
    
    .demo-accordion details {
    	box-sizing: border-box;
    	width: 100%;
    	max-width: 560px;
    	border: 1px solid var(--border);
    	border-radius: 8px;
    	margin-bottom: .5rem;
    	overflow: hidden;
    }
    
    .demo-accordion summary {
    	padding: .9rem 1.1rem;
    	font-weight: 600;
    	font-size: .95rem;
    	cursor: pointer;
    	list-style: none;
    	display: flex;
    	justify-content: space-between;
    	align-items: center;
    	background: var(--surface);
    	user-select: none;
    	transition: background var(--duration) var(--easing);
    }
    
    .demo-accordion summary::-webkit-details-marker {
    	display: none;
    }
    
    .demo-accordion summary::after {
    	content: "+";
    	font-size: 1.2rem;
    	font-weight: 400;
    	color: var(--accent);
    	transition: transform var(--duration) var(--easing);
    }
    
    /* the details clips its corners, so the ring sits inside the summary */
    .demo-accordion summary:focus-visible {
    	outline: 2px solid var(--accent);
    	outline-offset: -2px;
    }
    
    .demo-accordion details[open] summary {
    	background: var(--accent-dim);
    }
    
    .demo-accordion details[open] summary::after {
    	transform: rotate(45deg);
    }
    
    /* the panel: no height while closed, its content's height while open.
       content-visibility flips at the end of a close (allow-discrete), so the
       text stays painted while the panel shrinks */
    .demo-accordion details::details-content {
    	block-size: 0;
    	overflow: clip;
    	transition: block-size var(--duration) var(--easing), content-visibility var(--duration) var(--easing) allow-discrete;
    }
    
    .demo-accordion details[open]::details-content {
    	block-size: auto;
    }
    
    .demo-accordion .accordion-body {
    	padding: 1rem 1.1rem;
    	font-size: .9rem;
    	color: var(--text-muted);
    	border-top: 1px solid var(--border);
    	background: var(--surface);
    }
    
    @media (prefers-reduced-motion: reduce) {
    	.demo-accordion summary,
    	.demo-accordion summary::after,
    	.demo-accordion details::details-content {
    		transition: none;
    		animation: none;
    	}
    }

Test condition

One load each of the CSS version and jQuery UI, filmed on the slow phone test and played 4x slower. The CSS accordion works as soon as it shows. jQuery UI shows at 566 ms, but clicks do nothing until its script finishes at 1,024 ms (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 and images.

CSS
CSS: 1.6 KB, CSS 1.0 KB, HTML 0.6 KB
1.6 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.4 KB, JavaScript 1.7 KB, CSS 1.0 KB, HTML 0.7 KB
3.4 KB1.7 KB JavaScript
jQuery UI
jQuery UI: 124.3 KB, JavaScript 95.7 KB, CSS 7.4 KB, HTML 0.6 KB, Image or font 20.6 KB
124.3 KB95.7 KB JavaScript
jQuery UI, trimmed
jQuery UI, trimmed: 46.6 KB, JavaScript 33.6 KB, CSS 2.6 KB, HTML 0.6 KB, Image or font 9.8 KB
46.6 KB33.6 KB JavaScript
KB
CSS
CSS: 1.6 KB, CSS 1.0 KB, HTML 0.6 KB
1.6 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.4 KB, JavaScript 1.7 KB, CSS 1.0 KB, HTML 0.7 KB
3.4 KB1.7 KB JavaScript
jQuery UI
jQuery UI: 124.3 KB, JavaScript 95.7 KB, CSS 7.4 KB, HTML 0.6 KB, Image or font 20.6 KB
124.3 KB95.7 KB JavaScript
jQuery UI, trimmed
jQuery UI, trimmed: 46.6 KB, JavaScript 33.6 KB, CSS 2.6 KB, HTML 0.6 KB, Image or font 9.8 KB
46.6 KB33.6 KB JavaScript
KB
CSS
CSS: 1.6 KB, CSS 1.0 KB, HTML 0.6 KB
1.6 KBbest0 KB JavaScript
Vanilla JS
Vanilla JS: 3.4 KB, JavaScript 1.7 KB, CSS 1.0 KB, HTML 0.7 KB
3.4 KB1.7 KB JavaScript
jQuery UI
jQuery UI: 124.3 KB, JavaScript 95.7 KB, CSS 7.4 KB, HTML 0.6 KB, Image or font 20.6 KB
124.3 KB95.7 KB JavaScript
jQuery UI, trimmed
jQuery UI, trimmed: 46.6 KB, JavaScript 33.6 KB, CSS 2.6 KB, HTML 0.6 KB, Image or font 9.8 KB
46.6 KB33.6 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: 7.9 ms, CSS 5.2 ms, HTML 2.8 ms
7.9 msbest
Vanilla JS
Vanilla JS: 17 ms, JavaScript 8.5 ms, CSS 4.9 ms, HTML 3.5 ms
17 ms
jQuery UI
jQuery UI: 621 ms, JavaScript 478 ms, CSS 37 ms, HTML 2.9 ms, Image or font 103 ms
621 ms
jQuery UI, trimmed
jQuery UI, trimmed: 233 ms, JavaScript 168 ms, CSS 13 ms, HTML 2.9 ms, Image or font 49 ms
233 ms
ms
See the numbers
Accordion, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: accordion.cssCSS1,0325.2 ms
CSS: index.htmlHTML5522.8 ms
CSS total1,5847.9 ms
Vanilla JS: accordion.jsJavaScript1,6998.5 ms
Vanilla JS: accordion.cssCSS9854.9 ms
Vanilla JS: index.htmlHTML7023.5 ms
Vanilla JS total3,38617 ms
jQuery UI: init.jsJavaScript2411.2 ms
jQuery UI: jquery-ui.min.jsJavaScript67,881339 ms
jQuery UI: jquery.min.jsJavaScript27,530138 ms
jQuery UI: jquery-ui.min.cssCSS7,40737 ms
jQuery UI: index.htmlHTML5882.9 ms
jQuery UI: ui-icons_444444_256x240.pngImage or font7,10736 ms
jQuery UI: ui-icons_555555_256x240.pngImage or font7,10536 ms
jQuery UI: ui-icons_ffffff_256x240.pngImage or font6,39532 ms
jQuery UI total124,254621 ms
jQuery UI, trimmed: init.jsJavaScript2411.2 ms
jQuery UI, trimmed: jquery-ui.accordion.min.jsJavaScript5,87129 ms
jQuery UI, trimmed: jquery.min.jsJavaScript27,530138 ms
jQuery UI, trimmed: jquery-ui.accordion.min.cssCSS2,59413 ms
jQuery UI, trimmed: index.htmlHTML5842.9 ms
jQuery UI, trimmed: ui-icons_444444_256x240.pngImage or font3,26616 ms
jQuery UI, trimmed: ui-icons_555555_256x240.pngImage or font3,27416 ms
jQuery UI, trimmed: ui-icons_ffffff_256x240.pngImage or font3,26416 ms
jQuery UI, trimmed total46,624233 ms

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

CSS
CSS: 7.9 ms, CSS 5.2 ms, HTML 2.8 ms
7.9 msbest
Vanilla JS
Vanilla JS: 17 ms, JavaScript 8.5 ms, CSS 4.9 ms, HTML 3.5 ms
17 ms
jQuery UI
jQuery UI: 621 ms, JavaScript 478 ms, CSS 37 ms, HTML 2.9 ms, Image or font 103 ms
621 ms
jQuery UI, trimmed
jQuery UI, trimmed: 233 ms, JavaScript 168 ms, CSS 13 ms, HTML 2.9 ms, Image or font 49 ms
233 ms
ms
See the numbers
Accordion, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: accordion.cssCSS1,0325.2 ms
CSS: index.htmlHTML5522.8 ms
CSS total1,5847.9 ms
Vanilla JS: accordion.jsJavaScript1,6998.5 ms
Vanilla JS: accordion.cssCSS9854.9 ms
Vanilla JS: index.htmlHTML7023.5 ms
Vanilla JS total3,38617 ms
jQuery UI: init.jsJavaScript2411.2 ms
jQuery UI: jquery-ui.min.jsJavaScript67,881339 ms
jQuery UI: jquery.min.jsJavaScript27,530138 ms
jQuery UI: jquery-ui.min.cssCSS7,40737 ms
jQuery UI: index.htmlHTML5882.9 ms
jQuery UI: ui-icons_444444_256x240.pngImage or font7,10736 ms
jQuery UI: ui-icons_555555_256x240.pngImage or font7,10536 ms
jQuery UI: ui-icons_ffffff_256x240.pngImage or font6,39532 ms
jQuery UI total124,254621 ms
jQuery UI, trimmed: init.jsJavaScript2411.2 ms
jQuery UI, trimmed: jquery-ui.accordion.min.jsJavaScript5,87129 ms
jQuery UI, trimmed: jquery.min.jsJavaScript27,530138 ms
jQuery UI, trimmed: jquery-ui.accordion.min.cssCSS2,59413 ms
jQuery UI, trimmed: index.htmlHTML5842.9 ms
jQuery UI, trimmed: ui-icons_444444_256x240.pngImage or font3,26616 ms
jQuery UI, trimmed: ui-icons_555555_256x240.pngImage or font3,27416 ms
jQuery UI, trimmed: ui-icons_ffffff_256x240.pngImage or font3,26416 ms
jQuery UI, trimmed total46,624233 ms

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

CSS
CSS: 7.9 ms, CSS 5.2 ms, HTML 2.8 ms
7.9 msbest
Vanilla JS
Vanilla JS: 17 ms, JavaScript 8.5 ms, CSS 4.9 ms, HTML 3.5 ms
17 ms
jQuery UI
jQuery UI: 621 ms, JavaScript 478 ms, CSS 37 ms, HTML 2.9 ms, Image or font 103 ms
621 ms
jQuery UI, trimmed
jQuery UI, trimmed: 233 ms, JavaScript 168 ms, CSS 13 ms, HTML 2.9 ms, Image or font 49 ms
233 ms
ms
See the numbers
Accordion, every file each version downloads, gzipped.
FileKindBytesTime on slow 4G
CSS: accordion.cssCSS1,0325.2 ms
CSS: index.htmlHTML5522.8 ms
CSS total1,5847.9 ms
Vanilla JS: accordion.jsJavaScript1,6998.5 ms
Vanilla JS: accordion.cssCSS9854.9 ms
Vanilla JS: index.htmlHTML7023.5 ms
Vanilla JS total3,38617 ms
jQuery UI: init.jsJavaScript2411.2 ms
jQuery UI: jquery-ui.min.jsJavaScript67,881339 ms
jQuery UI: jquery.min.jsJavaScript27,530138 ms
jQuery UI: jquery-ui.min.cssCSS7,40737 ms
jQuery UI: index.htmlHTML5882.9 ms
jQuery UI: ui-icons_444444_256x240.pngImage or font7,10736 ms
jQuery UI: ui-icons_555555_256x240.pngImage or font7,10536 ms
jQuery UI: ui-icons_ffffff_256x240.pngImage or font6,39532 ms
jQuery UI total124,254621 ms
jQuery UI, trimmed: init.jsJavaScript2411.2 ms
jQuery UI, trimmed: jquery-ui.accordion.min.jsJavaScript5,87129 ms
jQuery UI, trimmed: jquery.min.jsJavaScript27,530138 ms
jQuery UI, trimmed: jquery-ui.accordion.min.cssCSS2,59413 ms
jQuery UI, trimmed: index.htmlHTML5842.9 ms
jQuery UI, trimmed: ui-icons_444444_256x240.pngImage or font3,26616 ms
jQuery UI, trimmed: ui-icons_555555_256x240.pngImage or font3,27416 ms
jQuery UI, trimmed: ui-icons_ffffff_256x240.pngImage or font3,26416 ms
jQuery UI, trimmed total46,624233 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 31 ms, works at 31 ms
31 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 33 ms, works at 33 ms
33 mstied bestworks when shown
jQuery UI
clicks do nothing yetjQuery UI: first paint at 36 ms, works at 65 ms, 28 ms when clicks do nothing
65 ms28 ms dead
jQuery UI, trimmed
clicks do nothing yetjQuery UI, trimmed: first paint at 35 ms, works at 57 ms, 22 ms when clicks do nothing
57 ms22 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
jQuery UI
Shows, clicks do nothingjQuery UI with JavaScript off: shows, clicks do nothing
Never
jQuery UI, trimmed
Shows, clicks do nothingjQuery UI, trimmed with JavaScript off: shows, clicks do nothing
Never
See the numbers
Accordion, 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
CSS31 ms31 ms0 msWorks
Vanilla JS33 ms33 ms0 msDoes not work
jQuery UI36 ms65 ms28 msShows, clicks do nothing
jQuery UI, trimmed35 ms57 ms22 msShows, clicks do nothing

Nothing on screenOn screen, clicks do nothing yetWorks

CSS
CSS: first paint at 455 ms, works at 455 ms
455 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 448 ms, works at 448 ms
448 mstied bestworks when shown
jQuery UI
clicks do nothing yetjQuery UI: first paint at 566 ms, works at 1,024 ms, 459 ms when clicks do nothing
1,024 ms459 ms dead
jQuery UI, trimmed
clicks do nothing yetjQuery UI, trimmed: first paint at 484 ms, works at 694 ms, 210 ms when clicks do nothing
694 ms210 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
jQuery UI
Shows, clicks do nothingjQuery UI with JavaScript off: shows, clicks do nothing
Never
jQuery UI, trimmed
Shows, clicks do nothingjQuery UI, trimmed with JavaScript off: shows, clicks do nothing
Never
See the numbers
Accordion, 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
CSS455 ms455 ms0 msWorks
Vanilla JS448 ms448 ms0 msDoes not work
jQuery UI566 ms1,024 ms459 msShows, clicks do nothing
jQuery UI, trimmed484 ms694 ms210 msShows, clicks do nothing

Nothing on screenOn screen, clicks do nothing yetWorks

CSS
CSS: first paint at 29 ms, works at 29 ms
29 mstied bestworks when shown
Vanilla JS
Vanilla JS: first paint at 34 ms, works at 34 ms
34 mstied bestworks when shown
jQuery UI
clicks do nothing yetjQuery UI: first paint at 34 ms, works at 63 ms, 28 ms when clicks do nothing
63 ms28 ms dead
jQuery UI, trimmed
clicks do nothing yetjQuery UI, trimmed: first paint at 33 ms, works at 53 ms, 20 ms when clicks do nothing
53 ms20 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
jQuery UI
Shows, clicks do nothingjQuery UI with JavaScript off: shows, clicks do nothing
Never
jQuery UI, trimmed
Shows, clicks do nothingjQuery UI, trimmed with JavaScript off: shows, clicks do nothing
Never
See the numbers
Accordion, 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
CSS29 ms29 ms0 msWorks
Vanilla JS34 ms34 ms0 msDoes not work
jQuery UI34 ms63 ms28 msShows, clicks do nothing
jQuery UI, trimmed33 ms53 ms20 msShows, clicks do nothing

Main thread while loading

Blocking timeTie with Vanilla JSTie with Vanilla JSTie with Vanilla JS

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 6.5 ms, 4.6 ms longCSS: task at 14 ms, 13 ms long
0 msblocking, 0 long tasks
Vanilla JS
Vanilla JS: task at 6.5 ms, 5.9 ms longVanilla JS: task at 17 ms, 12 ms long
0 msblocking, 0 long tasks
jQuery UI
jQuery UI: task at 6.4 ms, 4.9 ms longjQuery UI: task at 18 ms, 13 ms longjQuery UI: task at 32 ms, 4.4 ms longjQuery UI: task at 39 ms, 5.3 ms longjQuery UI: task at 46 ms, 16 ms long
0 msblocking, 0 long tasks
jQuery UI, trimmed
jQuery UI, trimmed: task at 6.1 ms, 6.4 ms longjQuery UI, trimmed: task at 17 ms, 12 ms longjQuery UI, trimmed: task at 35 ms, 16 ms long
0 msblocking, 0 long tasks
ms
See the numbers
Accordion, 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 task6.5 ms4.6 ms
CSS task14 ms13 ms
Vanilla JS0 ms blocking (median)0.6 ms script (median)0 long (median)
Vanilla JS task6.5 ms5.9 ms
Vanilla JS task17 ms12 ms
jQuery UI0 ms blocking (median)26 ms script (median)0 long (median)
jQuery UI task6.4 ms4.9 ms
jQuery UI task18 ms13 ms
jQuery UI task32 ms4.4 ms
jQuery UI task39 ms5.3 ms
jQuery UI task46 ms16 ms
jQuery UI, trimmed0 ms blocking (median)21 ms script (median)0 long (median)
jQuery UI, trimmed task6.1 ms6.4 ms
jQuery UI, trimmed task17 ms12 ms
jQuery UI, trimmed task35 ms16 ms

Main thread taskPart past 50 ms: a long task

CSS
CSS: task at 188 ms, 26 ms longCSS: task at 392 ms, 61 ms long, 11 ms past 50 ms (a long task)CSS: task at 3,506 ms, 7.5 ms longCSS: task at 3,514 ms, 14 ms long
0 mstied bestblocking, 1 long task
Vanilla JS
Vanilla JS: task at 191 ms, 25 ms longVanilla JS: task at 385 ms, 5.2 ms longVanilla JS: task at 394 ms, 57 ms long, 7.2 ms past 50 ms (a long task)Vanilla JS: task at 454 ms, 5.7 ms longVanilla JS: task at 3,549 ms, 9.2 ms longVanilla JS: task at 3,559 ms, 14 ms long
0 mstied bestblocking, 1 long task
jQuery UI
jQuery UI: task at 191 ms, 27 ms longjQuery UI: task at 486 ms, 67 ms long, 17 ms past 50 ms (a long task)jQuery UI: task at 687 ms, 17 ms longjQuery UI: task at 884 ms, 5.4 ms longjQuery UI: task at 892 ms, 23 ms longjQuery UI: task at 918 ms, 4.5 ms longjQuery UI: task at 923 ms, 87 ms long, 37 ms past 50 ms (a long task)jQuery UI: task at 1,013 ms, 5.5 ms longjQuery UI: task at 1,133 ms, 4.0 ms longjQuery UI: task at 4,047 ms, 6.1 ms longjQuery UI: task at 4,053 ms, 6.9 ms long
34 msblocking, 2 long tasks
jQuery UI, trimmed
jQuery UI, trimmed: task at 183 ms, 23 ms longjQuery UI, trimmed: task at 415 ms, 62 ms long, 12 ms past 50 ms (a long task)jQuery UI, trimmed: task at 562 ms, 4.2 ms longjQuery UI, trimmed: task at 567 ms, 19 ms longjQuery UI, trimmed: task at 595 ms, 85 ms long, 35 ms past 50 ms (a long task)jQuery UI, trimmed: task at 682 ms, 6.1 ms longjQuery UI, trimmed: task at 3,674 ms, 9.5 ms longjQuery UI, trimmed: task at 3,684 ms, 8.3 ms long
35 msblocking, 2 long tasks
ms
See the numbers
Accordion, 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 task188 ms26 ms
CSS task392 ms61 ms11 ms past 50 ms
CSS task3,506 ms7.5 ms
CSS task3,514 ms14 ms
Vanilla JS0 ms blocking (median)1.8 ms script (median)1 long (median)
Vanilla JS task191 ms25 ms
Vanilla JS task385 ms5.2 ms
Vanilla JS task394 ms57 ms7.2 ms past 50 ms
Vanilla JS task454 ms5.7 ms
Vanilla JS task3,549 ms9.2 ms
Vanilla JS task3,559 ms14 ms
jQuery UI34 ms blocking (median)131 ms script (median)2 long (median)
jQuery UI task191 ms27 ms
jQuery UI task486 ms67 ms17 ms past 50 ms
jQuery UI task687 ms17 ms
jQuery UI task884 ms5.4 ms
jQuery UI task892 ms23 ms
jQuery UI task918 ms4.5 ms
jQuery UI task923 ms87 ms37 ms past 50 ms
jQuery UI task1,013 ms5.5 ms
jQuery UI task1,133 ms4.0 ms
jQuery UI task4,047 ms6.1 ms
jQuery UI task4,053 ms6.9 ms
jQuery UI, trimmed35 ms blocking (median)108 ms script (median)2 long (median)
jQuery UI, trimmed task183 ms23 ms
jQuery UI, trimmed task415 ms62 ms12 ms past 50 ms
jQuery UI, trimmed task562 ms4.2 ms
jQuery UI, trimmed task567 ms19 ms
jQuery UI, trimmed task595 ms85 ms35 ms past 50 ms
jQuery UI, trimmed task682 ms6.1 ms
jQuery UI, trimmed task3,674 ms9.5 ms
jQuery UI, trimmed task3,684 ms8.3 ms

Main thread taskPart past 50 ms: a long task

CSS
CSS: task at 5.5 ms, 4.4 ms longCSS: task at 13 ms, 13 ms longCSS: task at 124 ms, 50 ms long, 0.4 ms past 50 ms (a long task)CSS: task at 224 ms, 50 ms longCSS: task at 323 ms, 50 ms longCSS: task at 421 ms, 50 ms longCSS: task at 518 ms, 50 ms longCSS: task at 613 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 724 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 819 ms, 50 ms longCSS: task at 915 ms, 50 ms longCSS: task at 1,012 ms, 50 ms longCSS: task at 1,121 ms, 50 ms longCSS: task at 1,217 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 1,312 ms, 50 ms longCSS: task at 1,423 ms, 50 ms long, 0.1 ms past 50 ms (a long task)CSS: task at 1,519 ms, 50 ms long, 0.1 ms past 50 ms (a long task)
0.9 msblocking, 6 long tasks
Vanilla JS
Vanilla JS: task at 5.3 ms, 4.4 ms longVanilla JS: task at 15 ms, 10 ms longVanilla JS: task at 111 ms, 50 ms long, 0.3 ms past 50 ms (a long task)Vanilla JS: task at 211 ms, 50 ms longVanilla JS: task at 311 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 422 ms, 50 ms longVanilla JS: task at 517 ms, 50 ms longVanilla JS: task at 612 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 818 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 914 ms, 50 ms longVanilla JS: task at 1,011 ms, 50 ms longVanilla JS: task at 1,121 ms, 50 ms long, 0.1 ms past 50 ms (a long task)Vanilla JS: task at 1,216 ms, 50 ms longVanilla JS: task at 1,310 ms, 50 ms longVanilla JS: task at 1,422 ms, 50 ms longVanilla JS: task at 1,517 ms, 50 ms long
0.8 msblocking, 6 long tasks
jQuery UI
jQuery UI: task at 6.4 ms, 5.3 ms longjQuery UI: task at 19 ms, 12 ms longjQuery UI: task at 31 ms, 4.4 ms longjQuery UI: task at 39 ms, 4.9 ms longjQuery UI: task at 45 ms, 15 ms longjQuery UI: task at 113 ms, 50 ms long, 0.2 ms past 50 ms (a long task)jQuery UI: task at 226 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 327 ms, 50 ms longjQuery UI: task at 427 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 523 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 618 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 712 ms, 50 ms longjQuery UI: task at 824 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 919 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 1,015 ms, 50 ms longjQuery UI: task at 1,126 ms, 50 ms longjQuery UI: task at 1,220 ms, 50 ms longjQuery UI: task at 1,316 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 1,412 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI: task at 1,523 ms, 50 ms longjQuery UI: task at 1,620 ms, 50 ms long
0.9 msblocking, 9 long tasks
jQuery UI, trimmed
jQuery UI, trimmed: task at 6.9 ms, 5.3 ms longjQuery UI, trimmed: task at 17 ms, 12 ms longjQuery UI, trimmed: task at 36 ms, 14 ms longjQuery UI, trimmed: task at 119 ms, 50 ms long, 0.3 ms past 50 ms (a long task)jQuery UI, trimmed: task at 219 ms, 50 ms longjQuery UI, trimmed: task at 319 ms, 50 ms longjQuery UI, trimmed: task at 416 ms, 50 ms longjQuery UI, trimmed: task at 527 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI, trimmed: task at 623 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI, trimmed: task at 718 ms, 50 ms longjQuery UI, trimmed: task at 814 ms, 50 ms longjQuery UI, trimmed: task at 926 ms, 50 ms longjQuery UI, trimmed: task at 1,023 ms, 50 ms longjQuery UI, trimmed: task at 1,117 ms, 50 ms longjQuery UI, trimmed: task at 1,213 ms, 50 ms longjQuery UI, trimmed: task at 1,324 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI, trimmed: task at 1,419 ms, 50 ms long, 0.1 ms past 50 ms (a long task)jQuery UI, trimmed: task at 1,514 ms, 50 ms longjQuery UI, trimmed: task at 1,626 ms, 50 ms long, 0.1 ms past 50 ms (a long task)
0.9 msblocking, 6 long tasks
ms
See the numbers
Accordion, Busy page. Tasks of 4 ms or more from one typical run; totals are medians of 15 runs.
VersionStarts atLastsLong task
CSS0.9 ms blocking (median)0 ms script (median)11 long (median)
CSS task5.5 ms4.4 ms
CSS task13 ms13 ms
CSS task124 ms50 ms0.4 ms past 50 ms
CSS task224 ms50 ms
CSS task323 ms50 ms
CSS task421 ms50 ms
CSS task518 ms50 ms
CSS task613 ms50 ms0.1 ms past 50 ms
CSS task724 ms50 ms0.1 ms past 50 ms
CSS task819 ms50 ms
CSS task915 ms50 ms
CSS task1,012 ms50 ms
CSS task1,121 ms50 ms
CSS task1,217 ms50 ms0.1 ms past 50 ms
CSS task1,312 ms50 ms
CSS task1,423 ms50 ms0.1 ms past 50 ms
CSS task1,519 ms50 ms0.1 ms past 50 ms
Vanilla JS0.8 ms blocking (median)0.6 ms script (median)12 long (median)
Vanilla JS task5.3 ms4.4 ms
Vanilla JS task15 ms10 ms
Vanilla JS task111 ms50 ms0.3 ms past 50 ms
Vanilla JS task211 ms50 ms
Vanilla JS task311 ms50 ms0.1 ms past 50 ms
Vanilla JS task422 ms50 ms
Vanilla JS task517 ms50 ms
Vanilla JS task612 ms50 ms0.1 ms past 50 ms
Vanilla JS task723 ms50 ms0.1 ms past 50 ms
Vanilla JS task818 ms50 ms0.1 ms past 50 ms
Vanilla JS task914 ms50 ms
Vanilla JS task1,011 ms50 ms
Vanilla JS task1,121 ms50 ms0.1 ms past 50 ms
Vanilla JS task1,216 ms50 ms
Vanilla JS task1,310 ms50 ms
Vanilla JS task1,422 ms50 ms
Vanilla JS task1,517 ms50 ms
jQuery UI0.9 ms blocking (median)25 ms script (median)12 long (median)
jQuery UI task6.4 ms5.3 ms
jQuery UI task19 ms12 ms
jQuery UI task31 ms4.4 ms
jQuery UI task39 ms4.9 ms
jQuery UI task45 ms15 ms
jQuery UI task113 ms50 ms0.2 ms past 50 ms
jQuery UI task226 ms50 ms0.1 ms past 50 ms
jQuery UI task327 ms50 ms
jQuery UI task427 ms50 ms0.1 ms past 50 ms
jQuery UI task523 ms50 ms0.1 ms past 50 ms
jQuery UI task618 ms50 ms0.1 ms past 50 ms
jQuery UI task712 ms50 ms
jQuery UI task824 ms50 ms0.1 ms past 50 ms
jQuery UI task919 ms50 ms0.1 ms past 50 ms
jQuery UI task1,015 ms50 ms
jQuery UI task1,126 ms50 ms
jQuery UI task1,220 ms50 ms
jQuery UI task1,316 ms50 ms0.1 ms past 50 ms
jQuery UI task1,412 ms50 ms0.1 ms past 50 ms
jQuery UI task1,523 ms50 ms
jQuery UI task1,620 ms50 ms
jQuery UI, trimmed0.9 ms blocking (median)19 ms script (median)11 long (median)
jQuery UI, trimmed task6.9 ms5.3 ms
jQuery UI, trimmed task17 ms12 ms
jQuery UI, trimmed task36 ms14 ms
jQuery UI, trimmed task119 ms50 ms0.3 ms past 50 ms
jQuery UI, trimmed task219 ms50 ms
jQuery UI, trimmed task319 ms50 ms
jQuery UI, trimmed task416 ms50 ms
jQuery UI, trimmed task527 ms50 ms0.1 ms past 50 ms
jQuery UI, trimmed task623 ms50 ms0.1 ms past 50 ms
jQuery UI, trimmed task718 ms50 ms
jQuery UI, trimmed task814 ms50 ms
jQuery UI, trimmed task926 ms50 ms
jQuery UI, trimmed task1,023 ms50 ms
jQuery UI, trimmed task1,117 ms50 ms
jQuery UI, trimmed task1,213 ms50 ms
jQuery UI, trimmed task1,324 ms50 ms0.1 ms past 50 ms
jQuery UI, trimmed task1,419 ms50 ms0.1 ms past 50 ms
jQuery UI, trimmed task1,514 ms50 ms
jQuery UI, trimmed task1,626 ms50 ms0.1 ms past 50 ms

Shows on screen after a click

Shows after a clickTie with Vanilla JSTie with Vanilla JSTie with jQuery UI, trimmed

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

One runMedian

CSS
CSS, run 4: shown 22 ms after the clickCSS, run 5: shown 22 ms after the clickCSS, run 9: shown 23 ms after the clickCSS, run 2: shown 24 ms after the clickCSS, run 7: shown 24 ms after the clickCSS, run 6: shown 24 ms after the clickCSS, run 10: shown 25 ms after the clickCSS, run 8: shown 25 ms after the clickCSS, run 1: shown 25 ms after the clickCSS, run 3: shown 25 ms after the clickCSS, run 14: shown 29 ms after the clickCSS, run 13: shown 30 ms after the clickCSS, run 11: shown 30 ms after the clickCSS, run 15: shown 30 ms after the clickCSS, run 12: shown 32 ms after the click
25 msmedian
Vanilla JS
Vanilla JS, run 6: shown 22 ms after the clickVanilla JS, run 4: shown 23 ms after the clickVanilla JS, run 7: shown 23 ms after the clickVanilla JS, run 5: shown 23 ms after the clickVanilla JS, run 3: shown 23 ms after the clickVanilla JS, run 9: shown 23 ms after the clickVanilla JS, run 2: shown 23 ms after the clickVanilla JS, run 10: shown 24 ms after the clickVanilla JS, run 1: shown 25 ms after the clickVanilla JS, run 13: shown 30 ms after the clickVanilla JS, run 14: shown 30 ms after the clickVanilla JS, run 15: shown 30 ms after the clickVanilla JS, run 12: shown 31 ms after the clickVanilla JS, run 11: shown 32 ms after the clickVanilla JS, run 8: shown 44 ms after the click
24 msmedian
jQuery UI
jQuery UI, run 8: shown 22 ms after the clickjQuery UI, run 3: shown 22 ms after the clickjQuery UI, run 4: shown 22 ms after the clickjQuery UI, run 7: shown 23 ms after the clickjQuery UI, run 10: shown 23 ms after the clickjQuery UI, run 5: shown 24 ms after the clickjQuery UI, run 9: shown 24 ms after the clickjQuery UI, run 2: shown 24 ms after the clickjQuery UI, run 6: shown 24 ms after the clickjQuery UI, run 1: shown 25 ms after the clickjQuery UI, run 15: shown 28 ms after the clickjQuery UI, run 14: shown 31 ms after the clickjQuery UI, run 11: shown 31 ms after the clickjQuery UI, run 12: shown 32 ms after the clickjQuery UI, run 13: shown 33 ms after the click
24 msmedian
jQuery UI, trimmed
jQuery UI, trimmed, run 3: shown 23 ms after the clickjQuery UI, trimmed, run 7: shown 23 ms after the clickjQuery UI, trimmed, run 6: shown 23 ms after the clickjQuery UI, trimmed, run 5: shown 23 ms after the clickjQuery UI, trimmed, run 8: shown 24 ms after the clickjQuery UI, trimmed, run 9: shown 24 ms after the clickjQuery UI, trimmed, run 4: shown 24 ms after the clickjQuery UI, trimmed, run 1: shown 25 ms after the clickjQuery UI, trimmed, run 10: shown 25 ms after the clickjQuery UI, trimmed, run 2: shown 25 ms after the clickjQuery UI, trimmed, run 15: shown 29 ms after the clickjQuery UI, trimmed, run 13: shown 29 ms after the clickjQuery UI, trimmed, run 14: shown 30 ms after the clickjQuery UI, trimmed, run 11: shown 31 ms after the clickjQuery UI, trimmed, run 12: shown 31 ms after the click
25 msmedian
ms after the click
See the numbers
Accordion, Laptop. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS25 ms24 ms to 29 ms25, 24, 25, 22, 22, 24, 24, 25, 23, 25, 30, 32, 30, 29, 30
Vanilla JS24 ms23 ms to 30 ms25, 23, 23, 23, 23, 22, 23, 44, 23, 24, 32, 31, 30, 30, 30
jQuery UI24 ms23 ms to 29 ms25, 24, 22, 22, 24, 24, 23, 22, 24, 23, 31, 32, 33, 31, 28
jQuery UI, trimmed25 ms23 ms to 29 ms25, 25, 23, 24, 23, 23, 23, 24, 24, 25, 31, 31, 29, 30, 29

One runMedian

CSS
CSS, run 12: shown 36 ms after the clickCSS, run 11: shown 37 ms after the clickCSS, run 9: shown 38 ms after the clickCSS, run 13: shown 38 ms after the clickCSS, run 6: shown 38 ms after the clickCSS, run 7: shown 39 ms after the clickCSS, run 10: shown 39 ms after the clickCSS, run 15: shown 39 ms after the clickCSS, run 5: shown 40 ms after the clickCSS, run 1: shown 41 ms after the clickCSS, run 3: shown 48 ms after the clickCSS, run 14: shown 50 ms after the clickCSS, run 8: shown 54 ms after the clickCSS, run 2: shown 55 ms after the clickCSS, run 4: shown 65 ms after the click
39 mstied bestmedian
Vanilla JS
Vanilla JS, run 8: shown 39 ms after the clickVanilla JS, run 7: shown 40 ms after the clickVanilla JS, run 11: shown 40 ms after the clickVanilla JS, run 12: shown 42 ms after the clickVanilla JS, run 3: shown 45 ms after the clickVanilla JS, run 14: shown 48 ms after the clickVanilla JS, run 4: shown 54 ms after the clickVanilla JS, run 1: shown 54 ms after the clickVanilla JS, run 9: shown 55 ms after the clickVanilla JS, run 6: shown 55 ms after the clickVanilla JS, run 5: shown 56 ms after the clickVanilla JS, run 10: shown 56 ms after the clickVanilla JS, run 15: shown 57 ms after the clickVanilla JS, run 13: shown 63 ms after the clickVanilla JS, run 2: shown 71 ms after the click
54 mstied bestmedian
jQuery UI
jQuery UI, run 12: shown 54 ms after the clickjQuery UI, run 1: shown 54 ms after the clickjQuery UI, run 15: shown 54 ms after the clickjQuery UI, run 7: shown 55 ms after the clickjQuery UI, run 9: shown 58 ms after the clickjQuery UI, run 13: shown 58 ms after the clickjQuery UI, run 5: shown 71 ms after the clickjQuery UI, run 10: shown 71 ms after the clickjQuery UI, run 2: shown 72 ms after the clickjQuery UI, run 11: shown 72 ms after the clickjQuery UI, run 8: shown 74 ms after the clickjQuery UI, run 14: shown 80 ms after the clickjQuery UI, run 4: shown 81 ms after the clickjQuery UI, run 3: shown 81 ms after the clickjQuery UI, run 6: shown 90 ms after the click
71 msmedian
jQuery UI, trimmed
jQuery UI, trimmed, run 7: shown 54 ms after the clickjQuery UI, trimmed, run 3: shown 64 ms after the clickjQuery UI, trimmed, run 10: shown 70 ms after the clickjQuery UI, trimmed, run 9: shown 71 ms after the clickjQuery UI, trimmed, run 11: shown 71 ms after the clickjQuery UI, trimmed, run 1: shown 71 ms after the clickjQuery UI, trimmed, run 2: shown 71 ms after the clickjQuery UI, trimmed, run 6: shown 72 ms after the clickjQuery UI, trimmed, run 4: shown 72 ms after the clickjQuery UI, trimmed, run 14: shown 72 ms after the clickjQuery UI, trimmed, run 8: shown 73 ms after the clickjQuery UI, trimmed, run 15: shown 73 ms after the clickjQuery UI, trimmed, run 5: shown 73 ms after the clickjQuery UI, trimmed, run 12: shown 74 ms after the clickjQuery UI, trimmed, run 13: shown 78 ms after the click
72 msmedian
ms after the click
See the numbers
Accordion, Phone, 4x slower. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS39 ms38 ms to 49 ms41, 55, 48, 65, 40, 38, 39, 54, 38, 39, 37, 36, 38, 50, 39
Vanilla JS54 ms44 ms to 56 ms54, 71, 45, 54, 56, 55, 40, 39, 55, 56, 40, 42, 63, 48, 57
jQuery UI71 ms57 ms to 77 ms54, 72, 81, 81, 71, 90, 55, 74, 58, 71, 72, 54, 58, 80, 54
jQuery UI, trimmed72 ms71 ms to 73 ms71, 71, 64, 72, 73, 72, 54, 73, 71, 70, 71, 74, 78, 72, 73

One runMedian

CSS
CSS, run 1: shown 22 ms after the clickCSS, run 11: shown 23 ms after the clickCSS, run 12: shown 23 ms after the clickCSS, run 4: shown 24 ms after the clickCSS, run 8: shown 24 ms after the clickCSS, run 9: shown 25 ms after the clickCSS, run 6: shown 42 ms after the clickCSS, run 3: shown 70 ms after the clickCSS, run 2: shown 71 ms after the clickCSS, run 7: shown 72 ms after the clickCSS, run 15: shown 74 ms after the clickCSS, run 14: shown 74 ms after the clickCSS, run 5: shown 74 ms after the clickCSS, run 10: shown 74 ms after the clickCSS, run 13: shown 93 ms after the click
70 msmedian
Vanilla JS
Vanilla JS, run 1: shown 22 ms after the clickVanilla JS, run 2: shown 25 ms after the clickVanilla JS, run 9: shown 25 ms after the clickVanilla JS, run 13: shown 43 ms after the clickVanilla JS, run 8: shown 44 ms after the clickVanilla JS, run 11: shown 71 ms after the clickVanilla JS, run 5: shown 72 ms after the clickVanilla JS, run 10: shown 74 ms after the clickVanilla JS, run 4: shown 74 ms after the clickVanilla JS, run 7: shown 75 ms after the clickVanilla JS, run 15: shown 75 ms after the clickVanilla JS, run 6: shown 75 ms after the clickVanilla JS, run 3: shown 76 ms after the clickVanilla JS, run 14: shown 92 ms after the clickVanilla JS, run 12: shown 93 ms after the click
74 msmedian
jQuery UI
jQuery UI, run 13: shown 22 ms after the clickjQuery UI, run 1: shown 23 ms after the clickjQuery UI, run 5: shown 23 ms after the clickjQuery UI, run 4: shown 24 ms after the clickjQuery UI, run 12: shown 24 ms after the clickjQuery UI, run 15: shown 24 ms after the clickjQuery UI, run 9: shown 25 ms after the clickjQuery UI, run 6: shown 71 ms after the clickjQuery UI, run 2: shown 73 ms after the clickjQuery UI, run 3: shown 74 ms after the clickjQuery UI, run 7: shown 74 ms after the clickjQuery UI, run 8: shown 74 ms after the clickjQuery UI, run 10: shown 75 ms after the clickjQuery UI, run 11: shown 79 ms after the clickjQuery UI, run 14: shown 93 ms after the click
71 msmedian
jQuery UI, trimmed
jQuery UI, trimmed, run 1: shown 22 ms after the clickjQuery UI, trimmed, run 15: shown 23 ms after the clickjQuery UI, trimmed, run 14: shown 23 ms after the clickjQuery UI, trimmed, run 2: shown 23 ms after the clickjQuery UI, trimmed, run 10: shown 23 ms after the clickjQuery UI, trimmed, run 6: shown 24 ms after the clickjQuery UI, trimmed, run 7: shown 24 ms after the clickjQuery UI, trimmed, run 12: shown 24 ms after the clickjQuery UI, trimmed, run 11: shown 71 ms after the clickjQuery UI, trimmed, run 5: shown 74 ms after the clickjQuery UI, trimmed, run 8: shown 74 ms after the clickjQuery UI, trimmed, run 13: shown 74 ms after the clickjQuery UI, trimmed, run 3: shown 76 ms after the clickjQuery UI, trimmed, run 4: shown 76 ms after the clickjQuery UI, trimmed, run 9: shown 76 ms after the click
24 msmedian
ms after the click
See the numbers
Accordion, Busy page. Time from the click until the screen first changed, every run.
VersionMedianMiddle half of runsEvery run (ms)
CSS70 ms24 ms to 74 ms22, 71, 70, 24, 74, 42, 72, 24, 25, 74, 23, 23, 93, 74, 74
Vanilla JS74 ms43 ms to 75 ms22, 25, 76, 74, 72, 75, 75, 44, 25, 74, 71, 93, 43, 92, 75
jQuery UI71 ms24 ms to 74 ms23, 73, 74, 24, 23, 71, 74, 74, 25, 75, 79, 24, 22, 93, 24
jQuery UI, trimmed24 ms23 ms to 74 ms22, 23, 76, 76, 74, 24, 24, 74, 76, 23, 71, 24, 74, 23, 23

Smoothness while it opens

Frames that changedTie with Vanilla JSjQuery UI winsTie 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: 24 painted frames over 383 ms, 24 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 24 ms after the click.
100% changedtied best17 ms longest still
Vanilla JS
Vanilla JS: 24 painted frames over 383 ms, 24 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 23 ms after the click.
100% changedtied best17 ms longest still
jQuery UI
jQuery UI: 24 painted frames over 417 ms, 24 changed the picture. Longest still stretch in this run 33 ms. In this run the first change came 24 ms after the click.
96.2% changed33 ms longest still
jQuery UI, trimmed
jQuery UI, trimmed: 25 painted frames over 417 ms, 25 changed the picture. Longest still stretch in this run 33 ms. In this run the first change came 25 ms after the click.
96.2% changed33 ms longest still
ms after it starts moving
See the numbers
Accordion, 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 ms2424 ms0, 17, 34, 50, 67, 83, 100, 117, 133, 150, 167, 184, 200, 217, 234, 250, 267, 283, 300, 317, 333, 350, 367, 383
Vanilla JS100%17 ms2423 ms0, 17, 33, 50, 67, 83, 100, 117, 133, 150, 167, 184, 200, 217, 233, 250, 267, 284, 300, 317, 333, 350, 367, 383
jQuery UI96.2%33 ms2524 ms0, 17, 50, 67, 84, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 417
jQuery UI, trimmed96.2%33 ms2525 ms0, 17, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 234, 250, 267, 283, 300, 317, 334, 350, 367, 383, 400, 417

Frame that changed the pictureFrame painted, picture stillLongest still stretch

CSS
CSS: 25 painted frames over 400 ms, 24 changed the picture. Longest still stretch in this run 33 ms. In this run the first change came 39 ms after the click.
96% changed33 ms longest still
Vanilla JS
Vanilla JS: 25 painted frames over 400 ms, 24 changed the picture. Longest still stretch in this run 33 ms. In this run the first change came 42 ms after the click.
96% changed33 ms longest still
jQuery UI
jQuery UI: 25 painted frames over 400 ms, 25 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 72 ms after the click.
100% changedtied best17 ms longest still
jQuery UI, trimmed
jQuery UI, trimmed: 25 painted frames over 400 ms, 25 changed the picture. Longest still stretch in this run 17 ms. In this run the first change came 73 ms after the click.
100% changedtied best17 ms longest still
ms after it starts moving
See the numbers
Accordion, 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)
CSS96%33 ms2439 ms0, 17 still, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400
Vanilla JS96%33 ms2442 ms0, 17 still, 33, 50, 67, 83, 100, 117, 133, 150, 167, 183, 200, 217, 233, 250, 267, 283, 300, 317, 333, 350, 367, 383, 400
jQuery UI100%17 ms2572 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
jQuery UI, trimmed100%17 ms2473 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

Frame that changed the pictureFrame painted, picture stillLongest still stretch

CSS
CSS: 25 painted frames over 417 ms, 17 changed the picture. Longest still stretch in this run 67 ms. In this run the first change came 72 ms after the click.
69.2% changedtied best67 ms longest still
Vanilla JS
Vanilla JS: 25 painted frames over 415 ms, 18 changed the picture. Longest still stretch in this run 50 ms. In this run the first change came 93 ms after the click.
68% changedtied best50 ms longest still
jQuery UI
jQuery UI: 17 painted frames over 417 ms, 17 changed the picture. Longest still stretch in this run 67 ms. In this run the first change came 22 ms after the click.
65.4% changed67 ms longest still
jQuery UI, trimmed
jQuery UI, trimmed: 17 painted frames over 417 ms, 17 changed the picture. Longest still stretch in this run 67 ms. In this run the first change came 24 ms after the click.
61.5% changedtied best67 ms longest still
ms after it starts moving
See the numbers
Accordion, 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)
CSS69.2%67 ms1872 ms0, 17, 33, 50, 67 still, 100 still, 117, 133 still, 150, 167, 183 still, 200, 217, 234, 250, 267, 283 still, 300, 317 still, 333, 350, 367, 383 still, 400 still, 417
Vanilla JS68%50 ms1793 ms0, 15 still, 32, 48 still, 65 still, 82, 98, 115, 132, 148 still, 182, 199, 215, 232, 248, 265 still, 282, 299, 315, 332, 349, 365 still, 382 still, 398, 415
jQuery UI65.4%67 ms1722 ms0, 17, 83, 100, 117, 133, 183, 200, 217, 233, 283, 300, 317, 333, 383, 400, 417
jQuery UI, trimmed61.5%67 ms1724 ms0, 17, 83, 100, 116, 133, 183, 200, 217, 233, 283, 300, 317, 333, 383, 400, 417

Measure by measure

  • Against jQuery UI: CSS wins 8 of 11, ties 3, loses 0.
  • Against jQuery UI, trimmed: CSS wins 8 of 11, ties 3, 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.

Accordion, Laptop: CSS against each JavaScript version
MeasureCSS against jQuery UICSS against jQuery UI, trimmedCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS1.6 KBjQuery UI, trimmed46.6 KBCSS aheadCSS1.6 KBVanilla JS3.4 KB
JavaScript downloadedCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 KBjQuery UI, trimmed33.6 KBCSS far aheadCSS0 KBVanilla JS1.7 KB
Script time while loadingCSS far aheadCSS0 msjQuery UI26 msCSS far aheadCSS0 msjQuery UI, trimmed21 msTieCSS0 msVanilla JS0.6 ms
Blocking timeTieCSS0 msjQuery UI0 msTieCSS0 msjQuery UI, trimmed0 msTieCSS0 msVanilla JS0 ms
Time until it worksCSS aheadCSS31 msjQuery UI65 msCSS aheadCSS31 msjQuery UI, trimmed57 msTieCSS31 msVanilla JS33 ms
Layout shift while loadingCSS slightly aheadCSS0jQuery UI0.009CSS slightly aheadCSS0jQuery UI, trimmed0.009TieCSS0Vanilla JS0
Shows after a clickTieCSS25 msjQuery UI24 msTieCSS25 msjQuery UI, trimmed25 msTieCSS25 msVanilla JS24 ms
Click responseTieCSS6.2 msjQuery UI9.3 msTieCSS6.2 msjQuery UI, trimmed12 msTieCSS6.2 msVanilla JS14 ms
Frames that changedCSS slightly aheadCSS100%jQuery UI96.2%CSS slightly aheadCSS100%jQuery UI, trimmed96.2%TieCSS100%Vanilla JS100%
Works with JavaScript offCSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSSworksjQuery UI, trimmedshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS116 linesjQuery UI24,954 linesCSS far aheadCSS116 linesjQuery UI, trimmed9,691 linesCSS aheadCSS116 linesVanilla JS212 lines
  • Against jQuery UI: CSS wins 10 of 11, ties 0, loses 1.
  • Against jQuery UI, trimmed: CSS wins 10 of 11, ties 0, 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.

Accordion, Phone, 4x slower: CSS against each JavaScript version
MeasureCSS against jQuery UICSS against jQuery UI, trimmedCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS1.6 KBjQuery UI, trimmed46.6 KBCSS aheadCSS1.6 KBVanilla JS3.4 KB
JavaScript downloadedCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 KBjQuery UI, trimmed33.6 KBCSS far aheadCSS0 KBVanilla JS1.7 KB
Script time while loadingCSS far aheadCSS0 msjQuery UI131 msCSS far aheadCSS0 msjQuery UI, trimmed108 msTieCSS0 msVanilla JS1.8 ms
Blocking timeCSS far aheadCSS0 msjQuery UI34 msCSS far aheadCSS0 msjQuery UI, trimmed35 msTieCSS0 msVanilla JS0 ms
Time until it worksCSS aheadCSS455 msjQuery UI1,024 msCSS aheadCSS455 msjQuery UI, trimmed694 msTieCSS455 msVanilla JS448 ms
Layout shift while loadingCSS slightly aheadCSS0jQuery UI0.034CSS slightly aheadCSS0jQuery UI, trimmed0.034TieCSS0Vanilla JS0
Shows after a clickCSS aheadCSS39 msjQuery UI71 msCSS aheadCSS39 msjQuery UI, trimmed72 msTieCSS39 msVanilla JS54 ms
Click responseCSS aheadCSS18 msjQuery UI44 msCSS aheadCSS18 msjQuery UI, trimmed47 msTieCSS18 msVanilla JS27 ms
Frames that changedjQuery UI slightly aheadCSS96%jQuery UI100%jQuery UI, trimmed slightly aheadCSS96%jQuery UI, trimmed100%TieCSS96%Vanilla JS96%
Works with JavaScript offCSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSSworksjQuery UI, trimmedshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS116 linesjQuery UI24,954 linesCSS far aheadCSS116 linesjQuery UI, trimmed9,691 linesCSS aheadCSS116 linesVanilla JS212 lines
  • Against jQuery UI: CSS wins 8 of 11, ties 3, loses 0.
  • Against jQuery UI, trimmed: CSS wins 7 of 11, ties 4, 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.

Accordion, Busy page: CSS against each JavaScript version
MeasureCSS against jQuery UICSS against jQuery UI, trimmedCSS against Vanilla JS
Bytes downloadedCSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS1.6 KBjQuery UI, trimmed46.6 KBCSS aheadCSS1.6 KBVanilla JS3.4 KB
JavaScript downloadedCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 KBjQuery UI, trimmed33.6 KBCSS far aheadCSS0 KBVanilla JS1.7 KB
Script time while loadingCSS far aheadCSS0 msjQuery UI25 msCSS far aheadCSS0 msjQuery UI, trimmed19 msTieCSS0 msVanilla JS0.6 ms
Blocking timeTieCSS0.9 msjQuery UI0.9 msTieCSS0.9 msjQuery UI, trimmed0.9 msTieCSS0.9 msVanilla JS0.8 ms
Time until it worksCSS aheadCSS29 msjQuery UI63 msCSS aheadCSS29 msjQuery UI, trimmed53 msTieCSS29 msVanilla JS34 ms
Layout shift while loadingCSS slightly aheadCSS0jQuery UI0.009CSS slightly aheadCSS0jQuery UI, trimmed0.009TieCSS0Vanilla JS0
Shows after a clickTieCSS70 msjQuery UI71 msTieCSS70 msjQuery UI, trimmed24 msTieCSS70 msVanilla JS74 ms
Click responseTieCSS3.6 msjQuery UI6.5 msTieCSS3.6 msjQuery UI, trimmed6.8 msTieCSS3.6 msVanilla JS4.1 ms
Frames that changedCSS slightly aheadCSS69.2%jQuery UI65.4%TieCSS69.2%jQuery UI, trimmed61.5%TieCSS69.2%Vanilla JS68%
Works with JavaScript offCSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSSworksjQuery UI, trimmedshows, clicks do nothingCSS far aheadCSSworksVanilla JSdoes not work
Lines of codeCSS far aheadCSS116 linesjQuery UI24,954 linesCSS far aheadCSS116 linesjQuery UI, trimmed9,691 linesCSS aheadCSS116 linesVanilla JS212 lines

The code

CSS takes more lines to write: 116 against 30 for jQuery UI. With jQuery UI's library code included, the total is 24,954 lines against 116 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: 116 lines, 116 you write
116 linesbest116 you writeno library
Vanilla JS
Vanilla JS: 212 lines, 212 you write
212 lines212 you writeno library
jQuery UI
jQuery UI: 24,954 lines, 30 you write, 24,924 the library brings
24,954 lines30 you write24,924 library
jQuery UI, trimmed
jQuery UI, trimmed: 9,691 lines, 30 you write, 9,661 the library brings
9,691 lines30 you write9,661 library
lines
See the numbers
Accordion, 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: accordion.cssYou write, CSS91
CSS: index.htmlYou write, HTML25
CSS total116 you write, 0 from the library116
Vanilla JS: accordion.cssYou write, CSS92
Vanilla JS: accordion.jsYou write, JavaScript82
Vanilla JS: index.htmlYou write, HTML38
Vanilla JS total212 you write, 0 from the library212
jQuery UI: index.htmlYou write, HTML22
jQuery UI: init.jsYou write, JavaScript8
jQuery UI: jquery-ui/dist/themes/base/jquery-ui.cssLibrary, CSS1,246
jQuery UI: jquery/dist/jquery.jsLibrary, JavaScript7,877
jQuery UI: jquery-ui/dist/jquery-ui.jsLibrary, JavaScript15,801
jQuery UI total30 you write, 24,924 from the library24,954
jQuery UI, trimmed: index.htmlYou write, HTML22
jQuery UI, trimmed: init.jsYou write, JavaScript8
jQuery UI, trimmed: jquery/dist/jquery.jsLibrary, JavaScript7,877
jQuery UI, trimmed: jquery-ui/themes/base/core.cssLibrary, CSS87
jQuery UI, trimmed: jquery-ui/themes/base/accordion.cssLibrary, CSS23
jQuery UI, trimmed: jquery-ui/themes/base/theme.cssLibrary, CSS426
jQuery UI, trimmed: jquery-ui/ui/version.jsLibrary, JavaScript14
jQuery UI, trimmed: jquery-ui/ui/keycode.jsLibrary, JavaScript42
jQuery UI, trimmed: jquery-ui/ui/unique-id.jsLibrary, JavaScript43
jQuery UI, trimmed: jquery-ui/ui/widget.jsLibrary, JavaScript624
jQuery UI, trimmed: jquery-ui/ui/widgets/accordion.jsLibrary, JavaScript525
jQuery UI, trimmed total30 you write, 9,661 from the library9,691
The jQuery UI version30 lines in 2 files

index.html22 lines

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Accordion: jQuery UI 1.14.2</title>
<link rel="stylesheet" href="/vendor/jquery-ui/dist/themes/base/jquery-ui.min.css">
</head>
<body>
<div id="accordion" class="demo-accordion">
	<h3>What is Pure CSS?</h3>
	<div>Pure CSS refers to techniques that achieve interactive UI patterns using only CSS, with no JavaScript required.</div>
	<h3>Which browsers are supported?</h3>
	<div>All modern browsers support the features used in these examples. Check caniuse.com for specific properties.</div>
	<h3>Can I use these in production?</h3>
	<div>Yes! These are real CSS techniques used in production sites. Always consider accessibility requirements for your use case.</div>
</div>
<script src="/vendor/jquery/dist/jquery.min.js"></script>
<script src="/vendor/jquery-ui/dist/jquery-ui.min.js"></script>
<script src="init.js"></script>
</body>
</html>

init.js8 lines

// jQuery UI Accordion, initialized as its demo does (jqueryui.com/accordion/).
// One override: collapsible, so the open panel can be closed and none are open.
// Everything else, the 400ms "swing" animation included, is the library default.
$( function() {
	$( "#accordion" ).accordion( {
		collapsible: true
	} );
} );
jQuery UI 1.14.2: the library files it loads, gzipped
FileKindSize
jquery-ui.min.cssCSS7.4 KB
jquery.min.jsJavaScript27.5 KB
jquery-ui.min.jsJavaScript67.9 KB
ui-icons_ffffff_256x240.pngImage6.4 KB
ui-icons_444444_256x240.pngImage7.1 KB
ui-icons_555555_256x240.pngImage7.1 KB
Total123.4 KB

The trimmed build runs the same markup and init.js.

jQuery UI 1.14.2, trimmed to the accordion: the library files it loads, gzipped
FileKindSize
jquery-ui.accordion.min.cssCSS2.6 KB
jquery-ui.accordion.min.jsJavaScript5.9 KB
jquery.min.jsJavaScript27.5 KB
ui-icons_ffffff_256x240.pngImage3.3 KB
ui-icons_444444_256x240.pngImage3.3 KB
ui-icons_555555_256x240.pngImage3.3 KB
Total45.8 KB
The vanilla JavaScript version212 lines in 3 files

A careful version with arrow, Home and End keys and a CSS height transition.

index.html38 lines

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Accordion: vanilla JavaScript</title>
<link rel="stylesheet" href="accordion.css">
<script src="accordion.js" defer></script>
</head>
<body>
<div class="demo-accordion" data-accordion>
	<div class="accordion-item">
		<h3 class="accordion-heading">
			<button type="button" class="accordion-trigger" id="faq-head-1" aria-expanded="true" aria-controls="faq-panel-1">What is Pure CSS?</button>
		</h3>
		<div class="accordion-panel" id="faq-panel-1" role="region" aria-labelledby="faq-head-1">
			<div class="accordion-body">Pure CSS refers to techniques that achieve interactive UI patterns using only CSS, with no JavaScript required.</div>
		</div>
	</div>
	<div class="accordion-item">
		<h3 class="accordion-heading">
			<button type="button" class="accordion-trigger" id="faq-head-2" aria-expanded="false" aria-controls="faq-panel-2">Which browsers are supported?</button>
		</h3>
		<div class="accordion-panel" id="faq-panel-2" role="region" aria-labelledby="faq-head-2" hidden>
			<div class="accordion-body">All modern browsers support the features used in these examples. Check caniuse.com for specific properties.</div>
		</div>
	</div>
	<div class="accordion-item">
		<h3 class="accordion-heading">
			<button type="button" class="accordion-trigger" id="faq-head-3" aria-expanded="false" aria-controls="faq-panel-3">Can I use these in production?</button>
		</h3>
		<div class="accordion-panel" id="faq-panel-3" role="region" aria-labelledby="faq-head-3" hidden>
			<div class="accordion-body">Yes! These are real CSS techniques used in production sites. Always consider accessibility requirements for your use case.</div>
		</div>
	</div>
</div>
</body>
</html>

accordion.css92 lines

/*
 * Accordion, vanilla JavaScript version (purecss.com test rig)
 * The same look as the CSS version. accordion.js sets the panel height and
 * this file transitions it, with jQuery UI's default timing: 400ms "swing",
 * drawn here as cubic-bezier(0.37, 0, 0.63, 1).
 */

.demo-accordion {
	--surface: #ffffff;
	--border: #d0ccc0;
	--text: #1a1a1a;
	--text-muted: #5c5c55;
	--accent: #6f2fd6;
	--accent-dim: rgba(111, 47, 214, .08);
	--duration: 400ms;
	--easing: cubic-bezier(0.37, 0, 0.63, 1);
	display: flex;
	flex-direction: column;
	align-items: center;
	color: var(--text);
}

.demo-accordion .accordion-item {
	width: 100%;
	max-width: 560px;
	border: 1px solid var(--border);
	border-radius: 8px;
	margin-bottom: .5rem;
	overflow: hidden;
}

.demo-accordion .accordion-heading {
	margin: 0;
	font-size: inherit;
	font-weight: inherit;
}

.demo-accordion .accordion-trigger {
	width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	padding: .9rem 1.1rem;
	font: inherit;
	font-weight: 600;
	font-size: .95rem;
	text-align: left;
	color: inherit;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: var(--surface);
	user-select: none;
	transition: background var(--duration) var(--easing);
}

.demo-accordion .accordion-trigger::after {
	content: "+";
	font-size: 1.2rem;
	font-weight: 400;
	color: var(--accent);
	transition: transform var(--duration) var(--easing);
}

/* the item clips its corners, so the ring sits inside the button */
.demo-accordion .accordion-trigger:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.demo-accordion .accordion-trigger[aria-expanded="true"] {
	background: var(--accent-dim);
}

.demo-accordion .accordion-trigger[aria-expanded="true"]::after {
	transform: rotate(45deg);
}

/* the script sets a pixel height on this while it moves and clears it after;
   the padding is on .accordion-body, because padding here would not shrink
   to zero with the height */
.demo-accordion .accordion-panel {
	overflow: hidden;
	transition: height var(--duration) var(--easing);
}

.demo-accordion .accordion-body {
	padding: 1rem 1.1rem;
	font-size: .9rem;
	color: var(--text-muted);
	border-top: 1px solid var(--border);
	background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
	.demo-accordion .accordion-trigger,
	.demo-accordion .accordion-trigger::after,
	.demo-accordion .accordion-panel {
		transition: none;
		animation: none;
	}
}

accordion.js82 lines

// Accordion, vanilla JavaScript version (purecss.com test rig).
//
// Header buttons carry aria-expanded and aria-controls; panels are role="region" and get the
// hidden attribute once they finish closing. One panel is open at a time, and clicking the open
// header closes it. The height moves with a CSS transition (accordion.css, 400ms): this file only
// measures the content and sets the start and end heights.
//
// Keys match jQuery UI 1.14.2's accordion: Down or Right moves to the next header and Up or Left
// to the previous one (wrapping), Home and End go to the first and last, and Ctrl+Up inside a
// panel goes back to its header. Enter and Space come with <button>, and every header stays in
// the Tab order.
'use strict';

for (const accordion of document.querySelectorAll('[data-accordion]')) {
	const triggers = Array.from(accordion.querySelectorAll('.accordion-trigger'));
	const panelOf = (trigger) => document.getElementById(trigger.getAttribute('aria-controls'));
	const triggerOf = (panel) => document.getElementById(panel.getAttribute('aria-labelledby'));
	const isOpen = (trigger) => trigger.getAttribute('aria-expanded') === 'true';
	const fallbacks = new Map();

	// the resting state: an open panel back to its natural height, a closed one hidden
	function settle(panel) {
		clearTimeout(fallbacks.get(panel));
		panel.style.height = '';
		panel.hidden = !isOpen(triggerOf(panel));
	}

	function toggle(clicked) {
		const opening = !isOpen(clicked);
		const closing = triggers.filter(isOpen); // includes the clicked header when it is open
		const toClose = closing.map(panelOf);
		const toOpen = opening ? panelOf(clicked) : null;
		const moving = toOpen ? toClose.concat(toOpen) : toClose;

		// Reads first. A panel at rest has height auto, which cannot transition, so it is pinned
		// to its pixel height before it closes; a panel caught mid-move already has a pixel
		// height, and its transition carries on from wherever it is.
		const ms = parseFloat(getComputedStyle(panelOf(clicked)).transitionDuration) * 1000;
		const resting = toClose.filter((panel) => !panel.style.height);
		const heights = resting.map((panel) => panel.scrollHeight);

		for (const trigger of closing) trigger.setAttribute('aria-expanded', 'false');
		if (opening) clicked.setAttribute('aria-expanded', 'true');

		// reduced motion: no transition runs, so no transitionend comes; go straight to the end
		if (!ms) {
			moving.forEach(settle);
			return;
		}

		resting.forEach((panel, i) => { panel.style.height = `${heights[i]}px`; });
		if (toOpen && toOpen.hidden) {
			toOpen.hidden = false;
			toOpen.style.height = '0px';
		}
		// one layout with every start height in place, so the changes below transition from it
		let target = 0;
		if (toOpen) target = toOpen.scrollHeight;
		else if (resting.length) void accordion.offsetHeight;

		for (const panel of toClose) panel.style.height = '0px';
		if (toOpen) toOpen.style.height = `${target}px`;

		// transitionend settles each panel; the timer covers a transition that never starts
		for (const panel of moving) {
			clearTimeout(fallbacks.get(panel));
			fallbacks.set(panel, setTimeout(settle, ms + 50, panel));
		}
	}

	accordion.addEventListener('click', (event) => {
		const trigger = event.target.closest('.accordion-trigger');
		if (trigger && triggers.includes(trigger)) toggle(trigger);
	}, { passive: true });

	accordion.addEventListener('transitionend', (event) => {
		if (event.propertyName === 'height' && event.target.classList.contains('accordion-panel')) settle(event.target);
	}, { passive: true });

	accordion.addEventListener('keydown', (event) => {
		if (event.altKey) return;
		const index = triggers.indexOf(event.target);
		if (index < 0) {
			const panel = event.ctrlKey && event.key === 'ArrowUp' && event.target.closest('.accordion-panel');
			if (panel) triggerOf(panel).focus();
			return;
		}
		if (event.ctrlKey) return;
		const next = { ArrowDown: index + 1, ArrowRight: index + 1, ArrowUp: index - 1, ArrowLeft: index - 1, Home: 0, End: triggers.length - 1 }[event.key];
		if (next === undefined) return;
		event.preventDefault();
		triggers[(next + triggers.length) % triggers.length].focus();
	});
}

When JavaScript still makes sense

  • You need arrow keys between headers.

    <details> has no arrow, Home or End keys. jQuery UI and the vanilla version have them.

  • You want every panel the same height.

    jQuery UI sizes every panel to the tallest one by default, so the accordion keeps its height while switching panels. The CSS panels take their own height.

jQuery UI keeps only the open header in the Tab order (or the first header when none is open), so the other headers need the arrow keys. It also animates from script, which means it ignores the reduced motion setting.

Switching from jQuery UI

  1. Turn each header and the panel after it into one <details>, with the header text in its <summary>.
  2. Give every <details> in the group the same name, so opening one closes the others. Unlike jQuery UI's default, the open panel can also be closed from its own header, leaving none open.
  3. Add open to the <details> that starts open. jQuery UI opens the first one unless you set active.
  4. Wrap the <details> elements in a <div class="demo-accordion">, and give each panel's content a <div class="accordion-body"> wrapper.
  5. Copy the CSS. Its 400 ms matches jQuery UI's default duration.
  6. Delete the .accordion() call, and delete jquery-ui.min.js (67.9 KB), the theme stylesheet (7.4 KB), its icons (20.6 KB), and jquery.min.js (27.5 KB) unless something else on the page needs them.
  7. If your script listened for the activate event, listen for toggle on each <details> instead. activate fires once per switch, after the animation completes. toggle fires twice: once on the <details> that closes, once on the one that opens, each when its state changes.

jQuery UI settings in HTML and CSS

jQuery UI settingIn HTML and CSS
activeAdd open to the <details> that should start open. Leave it off every panel to start with all closed.
collapsibleThe open panel can be closed from its own header, leaving none open. No CSS keeps one panel always open.
headerThe first child of each <details>, its <summary>.
eventOpening a panel on hover so that it stays open has no HTML or CSS equivalent.
iconsDraw the icon with summary::after. Rotate it with details[open] summary::after, or swap it for a second icon.
animateSet the duration and curve in --duration and --easing, used by the transition on ::details-content.
classesAdd your own class names to the parts.
beforeActivateThe toggle event fires after a <details> has already changed and cannot stop the change.

Browser support

FeatureChromeFirefoxSafariEdge
<details name="faq">12013017.2120
::details-content13114318.4131
interpolate-size129NoNo129
transition-behavior11712917.4117

The figures come from MDN's browser compatibility data. In Firefox and Safari today, the panels open and close without the height animation because interpolate-size is not supported. In browsers older than Chrome 120, Edge 120, Firefox 130 and Safari 17.2, opening one panel no longer closes the others.

Questions

Can CSS replace a jQuery UI accordion?
<details name="faq"> keeps one panel open at a time and lets a reader close it, which is what collapsible: true does. What it lacks: arrow-key movement between headers, equal-height panels, and the height animation in Firefox and Safari.
Is a CSS accordion faster than jQuery UI?
On the slow phone test, the CSS version worked at 455 ms and jQuery UI at 1,024 ms, after 131 ms of script. A careful vanilla JavaScript version worked at 448 ms, a tie with CSS.
Does the CSS accordion work with JavaScript turned off?
With script off, the CSS version works. jQuery UI shows its content, but clicks do nothing. The vanilla version does not work.
How do I keep several panels open at once?
Leave name off the <details> elements, so any number of panels can sit open.
How do I make a panel open by default, or start with all closed?
The open attribute sets which panel starts open. Without it on any panel, all start closed. In a name group, if more than one panel has open, only the first starts open.
Does the panel resize when its content changes?
The CSS panel grows with its content. jQuery UI's default keeps its old height until refresh is called.
How do I build an accordion menu?
Nest <details> elements with their own name for each group. The inner panels keep their state when their outer panel closes.
CSS AccordionThis technique on its own page, with more ways to build it.