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.
On the laptop test, against the library the Accordion page tests (jQuery UI): CSS wins 8 of 11, ties 3, loses 0.
On the laptop test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.
On the slow phone test, against the library the Accordion page tests (jQuery UI): CSS wins 10 of 11, ties 0, loses 1.
On the slow phone test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.
On the busy page test, against the library the Accordion page tests (jQuery UI): CSS wins 8 of 11, ties 3, loses 0.
On the busy page test, against careful vanilla JavaScript on the Accordion page: CSS wins 4 of 11, ties 7, loses 0.
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 0
CSS wins: 8 of 11 measures, Accordion, against jQuery UI 8 Tie: 3 of 11 measures, Accordion, against jQuery UI 3 - Against vanilla JS
- CSS wins 4, ties 7, loses 0
CSS wins: 4 of 11 measures, Accordion, against Vanilla JS 4 Tie: 7 of 11 measures, Accordion, against Vanilla JS 7
- 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 1
CSS wins: 10 of 11 measures, Accordion, against jQuery UI 10 CSS loses: 1 of 11 measures, Accordion, against jQuery UI 1 - Against vanilla JS
- CSS wins 4, ties 7, loses 0
CSS wins: 4 of 11 measures, Accordion, against Vanilla JS 4 Tie: 7 of 11 measures, Accordion, against Vanilla JS 7
- 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 0
CSS wins: 8 of 11 measures, Accordion, against jQuery UI 8 Tie: 3 of 11 measures, Accordion, against jQuery UI 3 - Against vanilla JS
- CSS wins 4, ties 7, loses 0
CSS wins: 4 of 11 measures, Accordion, against Vanilla JS 4 Tie: 7 of 11 measures, Accordion, against Vanilla JS 7
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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst jQuery UI | CSS far aheadCSS1.6 KBjQuery UI124.3 KB | CSS far aheadCSS0 KBjQuery UI95.7 KB | CSS far aheadCSS0 msjQuery UI26 ms | TieCSS0 msjQuery UI0 ms | CSS aheadCSS31 msjQuery UI65 ms | CSS slightly aheadCSS0jQuery UI0.009 | TieCSS25 msjQuery UI24 ms | TieCSS6.2 msjQuery UI9.3 ms | CSS slightly aheadCSS100%jQuery UI96.2% | CSS far aheadCSSworksjQuery UIshows, clicks do nothing | CSS 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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst Vanilla JS | CSS aheadCSS1.6 KBVanilla JS3.4 KB | CSS far aheadCSS0 KBVanilla JS1.7 KB | TieCSS0 msVanilla JS0.6 ms | TieCSS0 msVanilla JS0 ms | TieCSS31 msVanilla JS33 ms | TieCSS0Vanilla JS0 | TieCSS25 msVanilla JS24 ms | TieCSS6.2 msVanilla JS14 ms | TieCSS100%Vanilla JS100% | CSS far aheadCSSworksVanilla JSdoes not work | CSS 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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst jQuery UI | CSS far aheadCSS1.6 KBjQuery UI124.3 KB | CSS far aheadCSS0 KBjQuery UI95.7 KB | CSS far aheadCSS0 msjQuery UI131 ms | CSS far aheadCSS0 msjQuery UI34 ms | CSS aheadCSS455 msjQuery UI1,024 ms | CSS slightly aheadCSS0jQuery UI0.034 | CSS aheadCSS39 msjQuery UI71 ms | CSS aheadCSS18 msjQuery UI44 ms | jQuery UI slightly aheadCSS96%jQuery UI100% | CSS far aheadCSSworksjQuery UIshows, clicks do nothing | CSS 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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst Vanilla JS | CSS aheadCSS1.6 KBVanilla JS3.4 KB | CSS far aheadCSS0 KBVanilla JS1.7 KB | TieCSS0 msVanilla JS1.8 ms | TieCSS0 msVanilla JS0 ms | TieCSS455 msVanilla JS448 ms | TieCSS0Vanilla JS0 | TieCSS39 msVanilla JS54 ms | TieCSS18 msVanilla JS27 ms | TieCSS96%Vanilla JS96% | CSS far aheadCSSworksVanilla JSdoes not work | CSS 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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst jQuery UI | CSS far aheadCSS1.6 KBjQuery UI124.3 KB | CSS far aheadCSS0 KBjQuery UI95.7 KB | CSS far aheadCSS0 msjQuery UI25 ms | TieCSS0.9 msjQuery UI0.9 ms | CSS aheadCSS29 msjQuery UI63 ms | CSS slightly aheadCSS0jQuery UI0.009 | TieCSS70 msjQuery UI71 ms | TieCSS3.6 msjQuery UI6.5 ms | CSS slightly aheadCSS69.2%jQuery UI65.4% | CSS far aheadCSSworksjQuery UIshows, clicks do nothing | CSS 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.
| Topic | Bytes downloaded | JavaScript downloaded | Script time while loading | Blocking time | Time until it works | Layout shift while loading | Shows after a click | Click response | Frames that changed | Works with JavaScript off | Lines of code |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Accordionagainst Vanilla JS | CSS aheadCSS1.6 KBVanilla JS3.4 KB | CSS far aheadCSS0 KBVanilla JS1.7 KB | TieCSS0 msVanilla JS0.6 ms | TieCSS0.9 msVanilla JS0.8 ms | TieCSS29 msVanilla JS34 ms | TieCSS0Vanilla JS0 | TieCSS70 msVanilla JS74 ms | TieCSS3.6 msVanilla JS4.1 ms | TieCSS69.2%Vanilla JS68% | CSS far aheadCSSworksVanilla JSdoes not work | CSS 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)
See the numbers
| Topic | CSS JavaScript bytes | Saved against vanilla | Saved against the library | Saved against the trimmed build |
|---|---|---|---|---|
| Accordion | 0 | 1,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)
See the numbers
| Topic | CSS JavaScript bytes | Saved against vanilla | Saved against the library | Saved against the trimmed build |
|---|---|---|---|---|
| Accordion | 0 | 1,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)
See the numbers
| Topic | CSS JavaScript bytes | Saved against vanilla | Saved against the library | Saved against the trimmed build |
|---|---|---|---|---|
| Accordion | 0 | 1,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