• Stars
    star
    919
  • Rank 48,116 (Top 1.0 %)
  • Language
    JavaScript
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Benchmarking Vite vs. Next + turbopack HMR performance

Vite vs. Next + turbopack HMR Benchmark

Methodology

  1. The two projects are created from the following commands:

    npx create-next-app@latest
    npm init vite@latest # select React preset
  2. genFiles.(m)js is run in each project to generate 1000 components. All components are imported in the app's root component (in Next's case, the root page component) and rendered together. This step is already done and the files are already checked in, but the script is included for reference.

  3. For Next, app/page.js has the 'use client' directive so it renders in client mode. This is necessary to ensure proper comparison, since server components incurs non-trivial HMR overhead (4x slower).

  4. For Vite, we are using vite-plugin-swc-react-refresh so that the React JSX & HMR transform are using swc instead of Babel. The reason Vite's default React plugin uses Babel is because using swc results in 58MB of extra install weight (when Vite itself is 19MB) for marginal HMR improvement. However, for the purpose of benchmarking, we should use the same transforms turbopack is using so that the comparison is focused on the HMR mechanisms of the two tools.

  5. For each project, we run watch.(m)js in a separate Node process to get the exact timestamp of file change. This is used to mark the start of HMR.

  6. Start the projects (vite and next dev --turbo), then edit the following files to test HMR:

    • Next: app/page.js (root) and app/comp0.jsx (leaf)
    • Vite: src/App.jsx (root) and src/components/comp0.jsx (leaf)

The edited components all render Date.now() in their output. The final rendered timestamp in the DOM is used to mark the completion of HMR.

Numbers

  • Recorded over 5 runs
  • Time in ms
  • Tested on M1 MacBook Pro
Vite (root) Vite (leaf) Next (client root) Next (client leaf) Next (RSC root) Next (RSC leaf)
1 342 141 335 87 782 661
2 358 141 343 72 912 633
3 352 143 334 88 922 453
4 337 139 337 85 829 640
5 302 145 324 90 737 539
Average 338.2 141.8 334.6 84.4 836.4 585.2

Notes

  • The Next RSC numbers are only included for reference (compare between server/client HMR in Next).
  • For the root component (big with many imports and child components), Vite and Next + turbopack are almost equally fast.
  • For the leaf component (small, no imports), Next + turbopack is about 68% faster.
  • This is quite far from the claim that "turbopack is 10x faster than Vite" as we've seen from Vercel's marketing materials.

More Repositories

1

build-your-own-mint

Build your own personal finance analytics using Plaid, Google Sheets and CircleCI.
HTML
2,456
star
2

vue-hooks

Experimental React hooks implementation in Vue
JavaScript
1,592
star
3

pod

Git push deploy for Node.js
JavaScript
1,345
star
4

zoomerang

drop in zoom anything
JavaScript
1,221
star
5

vue-lit

Proof of concept custom elements "framework"
JavaScript
1,105
star
6

HTML5-Clear-v2

HTML5 Clear version 2
JavaScript
948
star
7

laravel-vue-cli-3

Example project using Vue CLI 3 with Laravel
PHP
850
star
8

HTML5-Clear

[DEPRECATED] A replica of the Clear iphone app in HTML5
JavaScript
719
star
9

register-service-worker

A script to simplify service worker registration with hooks for common events.
JavaScript
635
star
10

vue-wordle

Wordle built with Vue, aka VVordle
TypeScript
573
star
11

launch-editor

Open file in editor from Node.js.
JavaScript
531
star
12

semi

To semicolon or not to semicolon; that is the question
JavaScript
304
star
13

vue-svelte-size-analysis

Comparing generated code size of Vue and Svelte components
JavaScript
300
star
14

okie

Dead simple worker threads pool
TypeScript
257
star
15

starz

Count a GitHub user's total stars
JavaScript
145
star
16

circular-json-es6

circular JSON.stringify and JSON.parse, for environments with native ES6 Map
JavaScript
128
star
17

pug-plain-loader

webpack loader that transforms pug templates to plain HTML
JavaScript
114
star
18

release-tag

GitHub action for auto creating a release on tag push
JavaScript
107
star
19

Speech.js

Simple wrapper for Chrome's web speech recognition API
JavaScript
97
star
20

retweeter

Auto retweet from another account using CircleCI scheduled workflows
JavaScript
59
star
21

matrix.js

Featherweight CSS3 3D engine
JavaScript
58
star
22

buble

a fork of buble with some vue-specific hacks, used in vue-template-es2015-compiler
JavaScript
54
star
23

nightwatch-helpers

custom assertions and commands for easier nightwatch tests
JavaScript
53
star
24

shell-task

Proof-of-concept then-able shell commands in node.
JavaScript
46
star
25

creative-html5

A class about JavaScript, html5 and creative coding.
JavaScript
46
star
26

vue-template-explorer

See how vue templates get compiled into render functions under the hood
Vue
44
star
27

QR.js

Simple HTML5 Canvas-based QR Code generation
JavaScript
42
star
28

vue-tsc-3.3-type-repro

Vue
37
star
29

material-color-scheme-es6

Material Theme color scheme tweaked for ES6
JavaScript
32
star
30

semi-sublime

Sublime Text 3 plugin for Semi
Python
32
star
31

vite-pre-transform-test

JavaScript
29
star
32

speech

component for Chrome speech recognition wrapper
JavaScript
29
star
33

raveal

Radially reveal an element
JavaScript
27
star
34

webpack-hmr-repro

JavaScript
27
star
35

cjs-module-lexer-rollup-reexports

JavaScript
25
star
36

roetem

meteor-like experiment with vue and rethinkdb
JavaScript
24
star
37

gulp-component

component plugin for gulp
JavaScript
22
star
38

tucao

吐槽专用
21
star
39

thread-loader-bug

JavaScript
20
star
40

browser-audio

Simple cross browser audio player
JavaScript
19
star
41

rollup-tostringtag-symbol-conflict

JavaScript
19
star
42

resolve-type-test

TypeScript
19
star
43

babel-preset-flow-vue

JavaScript
17
star
44

popSlides

javascript popup slideshow plugin based on jQuery
JavaScript
17
star
45

esbuild-exports-signature-repro

JavaScript
16
star
46

vue

vue bug
HTML
14
star
47

Puzzle-Demo

A slider puzzle game with CSS3 transitions.
JavaScript
14
star
48

rollup-commonjs-bug

JavaScript
14
star
49

capper

Capture canvas animations.
JavaScript
12
star
50

Socket-Play

iPhone-controlled HTML5 game concept demo
JavaScript
12
star
51

Kinect-Keylight

Kinect version of @hakimel 's Keylight
C++
11
star
52

showme

show me the code (for an npm package)
JavaScript
11
star
53

workerify

Component for easy inline web worker
JavaScript
10
star
54

de-indent

remove extra indent from a block of code
JavaScript
10
star
55

new

Scaffold a new project.
JavaScript
8
star
56

Telekinesis

User gesture input simulation.
JavaScript
8
star
57

whipcream

Chai-style chaining sugar for webdriverjs
JavaScript
8
star
58

babel-plugin-transform-es2015-classes-simple

JavaScript
7
star
59

emitter-fsm

EventEmitter based finite state machine
JavaScript
6
star
60

templates

Personal project scaffolding templates
JavaScript
5
star
61

choreo.js

Event-based flow control for interactive walkthroughs
JavaScript
4
star
62

gulp-jscoverage

JSCoverage instrumentation plugin for gulp
JavaScript
4
star
63

fancytext

Text with fancy transitions
JavaScript
4
star
64

gruntfile-yaml

write grunt config in yaml.
JavaScript
4
star
65

roller

One-dimensional touch scroller with momentum and elastic pagination
JavaScript
4
star
66

test-cli-preset

JavaScript
3
star
67

babel-preset-es2015-rollup-vue

babel-preset-es2015, minus modules, plus helpers
JavaScript
3
star
68

generator-extension

A Chrome extension generator
JavaScript
3
star
69

generator-dude

A personal Yeoman generator
JavaScript
3
star
70

blaze-local-state

Local reactive state for Blaze templates
JavaScript
3
star
71

tester

webhook tests.
JavaScript
2
star
72

gulp-component-updater

Gulp-friendly module to auto add/delete files in your component.json
JavaScript
2
star
73

grunt-component-add

Automatically add files to component.json
JavaScript
1
star