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.

CSS vs JavaScript

Each comparison sets a CSS technique against the JavaScript library people search for and a careful vanilla JavaScript version. The CSS version runs live on the page, the library in sandboxed frames, and the vanilla version as code.

Compare CSS with

On the laptop test, against the library the Accordion page tests (jQuery UI): CSS wins 8 of 11, ties 3, loses 0.

CSS wins: 8 of 11 measures, Accordion, against the library each page tests8Tie: 3 of 11 measures, Accordion, against the library each page tests3

On the laptop test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.

CSS wins: 4 of 11 measures, Accordion, against careful vanilla JavaScript4Tie: 7 of 11 measures, Accordion, against careful vanilla JavaScript7

On the slow phone test, against the library the Accordion page tests (jQuery UI): CSS wins 10 of 11, ties 0, loses 1.

CSS wins: 10 of 11 measures, Accordion, against the library each page tests10CSS loses: 1 of 11 measures, Accordion, against the library each page tests1

On the slow phone test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.

CSS wins: 4 of 11 measures, Accordion, against careful vanilla JavaScript4Tie: 7 of 11 measures, Accordion, against careful vanilla JavaScript7

On the busy page test, against the library the Accordion page tests (jQuery UI): CSS wins 8 of 11, ties 3, loses 0.

CSS wins: 8 of 11 measures, Accordion, against the library each page tests8Tie: 3 of 11 measures, Accordion, against the library each page tests3

On the busy page test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.

CSS wins: 4 of 11 measures, Accordion, against careful vanilla JavaScript4Tie: 7 of 11 measures, Accordion, against careful vanilla JavaScript7

CSS winsTieCSS loses

The comparisons

Test condition

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.

JavaScript Accordion vs CSS

<details name="faq"> against jQuery UI 1.14.2 Accordion, a trimmed jQuery UI build and vanilla JavaScript

JavaScript the CSS version skips
95.7 KBagainst jQuery UI; 33.6 KB against the trimmed build
Works on the laptop at
31 msjQuery UI 65 ms; jQuery UI, trimmed 57 ms; vanilla 33 ms
Against jQuery UI
CSS wins 8, ties 3, loses 0CSS wins: 8 of 11 measures, Accordion, against jQuery UI8Tie: 3 of 11 measures, Accordion, against jQuery UI3
Against vanilla JS
CSS wins 4, ties 7, loses 0CSS wins: 4 of 11 measures, Accordion, against Vanilla JS4Tie: 7 of 11 measures, Accordion, against Vanilla JS7
JavaScript the CSS version skips
95.7 KBagainst jQuery UI; 33.6 KB against the trimmed build
Works on the phone at
455 msjQuery UI 1,024 ms; jQuery UI, trimmed 694 ms; vanilla 448 ms
Against jQuery UI
CSS wins 10, ties 0, loses 1CSS wins: 10 of 11 measures, Accordion, against jQuery UI10CSS loses: 1 of 11 measures, Accordion, against jQuery UI1
Against vanilla JS
CSS wins 4, ties 7, loses 0CSS wins: 4 of 11 measures, Accordion, against Vanilla JS4Tie: 7 of 11 measures, Accordion, against Vanilla JS7
JavaScript the CSS version skips
95.7 KBagainst jQuery UI; 33.6 KB against the trimmed build
Works on the busy page at
29 msjQuery UI 63 ms; jQuery UI, trimmed 53 ms; vanilla 34 ms
Against jQuery UI
CSS wins 8, ties 3, loses 0CSS wins: 8 of 11 measures, Accordion, against jQuery UI8Tie: 3 of 11 measures, Accordion, against jQuery UI3
Against vanilla JS
CSS wins 4, ties 7, loses 0CSS wins: 4 of 11 measures, Accordion, against Vanilla JS4Tie: 7 of 11 measures, Accordion, against Vanilla JS7

Every measure, every topic

Each cell compares CSS with the version picked here, named in every row with its color. Green means CSS is ahead, red means that JavaScript version is ahead, gray is a tie.

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTiejQuery UI 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.

CSS against the library each page tests: jQuery UI. Laptop
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst jQuery UICSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 msjQuery UI26 msTieCSS0 msjQuery UI0 msCSS aheadCSS31 msjQuery UI65 msCSS slightly aheadCSS0jQuery UI0.009TieCSS25 msjQuery UI24 msTieCSS6.2 msjQuery UI9.3 msCSS slightly aheadCSS100%jQuery UI96.2%CSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSS116 linesjQuery UI24,954 lines

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieVanilla JS 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.

CSS against careful vanilla JavaScript. Laptop
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst Vanilla JSCSS aheadCSS1.6 KBVanilla JS3.4 KBCSS far aheadCSS0 KBVanilla JS1.7 KBTieCSS0 msVanilla JS0.6 msTieCSS0 msVanilla JS0 msTieCSS31 msVanilla JS33 msTieCSS0Vanilla JS0TieCSS25 msVanilla JS24 msTieCSS6.2 msVanilla JS14 msTieCSS100%Vanilla JS100%CSS far aheadCSSworksVanilla JSdoes not workCSS aheadCSS116 linesVanilla JS212 lines

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTiejQuery UI 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.

CSS against the library each page tests: jQuery UI. Phone, 4x slower
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst jQuery UICSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 msjQuery UI131 msCSS far aheadCSS0 msjQuery UI34 msCSS aheadCSS455 msjQuery UI1,024 msCSS slightly aheadCSS0jQuery UI0.034CSS aheadCSS39 msjQuery UI71 msCSS aheadCSS18 msjQuery UI44 msjQuery UI slightly aheadCSS96%jQuery UI100%CSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSS116 linesjQuery UI24,954 lines

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieVanilla JS 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.

CSS against careful vanilla JavaScript. Phone, 4x slower
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst Vanilla JSCSS aheadCSS1.6 KBVanilla JS3.4 KBCSS far aheadCSS0 KBVanilla JS1.7 KBTieCSS0 msVanilla JS1.8 msTieCSS0 msVanilla JS0 msTieCSS455 msVanilla JS448 msTieCSS0Vanilla JS0TieCSS39 msVanilla JS54 msTieCSS18 msVanilla JS27 msTieCSS96%Vanilla JS96%CSS far aheadCSSworksVanilla JSdoes not workCSS aheadCSS116 linesVanilla JS212 lines

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTiejQuery UI 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.

CSS against the library each page tests: jQuery UI. Busy page
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst jQuery UICSS far aheadCSS1.6 KBjQuery UI124.3 KBCSS far aheadCSS0 KBjQuery UI95.7 KBCSS far aheadCSS0 msjQuery UI25 msTieCSS0.9 msjQuery UI0.9 msCSS aheadCSS29 msjQuery UI63 msCSS slightly aheadCSS0jQuery UI0.009TieCSS70 msjQuery UI71 msTieCSS3.6 msjQuery UI6.5 msCSS slightly aheadCSS69.2%jQuery UI65.4%CSS far aheadCSSworksjQuery UIshows, clicks do nothingCSS far aheadCSS116 linesjQuery UI24,954 lines

CSS ahead: far (3x or more), ahead (1.5x to 3x), slightlyTieVanilla JS 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.

CSS against careful vanilla JavaScript. Busy page
TopicBytes downloadedJavaScript downloadedScript time while loadingBlocking timeTime until it worksLayout shift while loadingShows after a clickClick responseFrames that changedWorks with JavaScript offLines of code
Accordionagainst Vanilla JSCSS aheadCSS1.6 KBVanilla JS3.4 KBCSS far aheadCSS0 KBVanilla JS1.7 KBTieCSS0 msVanilla JS0.6 msTieCSS0.9 msVanilla JS0.8 msTieCSS29 msVanilla JS34 msTieCSS0Vanilla JS0TieCSS70 msVanilla JS74 msTieCSS3.6 msVanilla JS4.1 msTieCSS69.2%Vanilla JS68%CSS far aheadCSSworksVanilla JSdoes not workCSS aheadCSS116 linesVanilla JS212 lines

JavaScript the CSS versions skip

Gzipped JavaScript each JavaScript version downloads that its CSS version does not.

Against vanilla JSAgainst the library (jQuery UI)Against jQuery UI, trimmed (Accordion only)

Accordion
Accordion: 1.7 KB of JavaScript saved against Vanilla JSAccordion: 95.7 KB of JavaScript saved against jQuery UIAccordion: 33.6 KB of JavaScript saved against jQuery UI, trimmed
1.7 KB95.7 KB33.6 KB
KB of JavaScript
See the numbers
JavaScript bytes, gzipped, Laptop.
TopicCSS JavaScript bytesSaved against vanillaSaved against the librarySaved against the trimmed build
Accordion01,699 (Vanilla JS)95,652 (jQuery UI)33,642 (jQuery UI, trimmed)

Against vanilla JSAgainst the library (jQuery UI)Against jQuery UI, trimmed (Accordion only)

Accordion
Accordion: 1.7 KB of JavaScript saved against Vanilla JSAccordion: 95.7 KB of JavaScript saved against jQuery UIAccordion: 33.6 KB of JavaScript saved against jQuery UI, trimmed
1.7 KB95.7 KB33.6 KB
KB of JavaScript
See the numbers
JavaScript bytes, gzipped, Phone, 4x slower.
TopicCSS JavaScript bytesSaved against vanillaSaved against the librarySaved against the trimmed build
Accordion01,699 (Vanilla JS)95,652 (jQuery UI)33,642 (jQuery UI, trimmed)

Against vanilla JSAgainst the library (jQuery UI)Against jQuery UI, trimmed (Accordion only)

Accordion
Accordion: 1.7 KB of JavaScript saved against Vanilla JSAccordion: 95.7 KB of JavaScript saved against jQuery UIAccordion: 33.6 KB of JavaScript saved against jQuery UI, trimmed
1.7 KB95.7 KB33.6 KB
KB of JavaScript
See the numbers
JavaScript bytes, gzipped, Busy page.
TopicCSS JavaScript bytesSaved against vanillaSaved against the librarySaved against the trimmed build
Accordion01,699 (Vanilla JS)95,652 (jQuery UI)33,642 (jQuery UI, trimmed)

How the tests run

Three versions per technique: the CSS one, the most searched library (self-hosted), and a careful vanilla JavaScript version. Accordion also runs a trimmed library build.

Browser
Chrome 157.0.8103.79 (headless) on Windows 11, 11th Gen Intel Core i7-11800H @ 2.30GHz
Laptop
1280 x 800, no throttling
Phone, 4x slower
CPU 4x slower, slow 4G (150 ms round trip, 1.6 Mbps down, 750 kbps up), 390 x 844 at 2x
Busy page
1280 x 800, other script holding the main thread for 50 ms of every 100 ms
Runs
15 per version per test condition. JavaScript off checked once on the laptop test.
Screen
Recorded at 60 frames per second
Clicks
Click response is the time from the click until the browser has the next frame ready, the way Chrome counts it for Google's INP.
Measured
Nov 19, 2026