Skip to content

Reduce core bundle size in v11#5167

Open
JoviDeCroock wants to merge 4 commits into
mainfrom
JoviDeCroock/reduce-core-bundle-size
Open

Reduce core bundle size in v11#5167
JoviDeCroock wants to merge 4 commits into
mainfrom
JoviDeCroock/reduce-core-bundle-size

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member
  • Co-locating cloneElement with createElement benefits gzip with 8 bytes
  • We can check handled for error-checking once and later
  • We don't have to check oldVNode in children because it's always true (default empty_obj)
  • Reduce the mathml regex

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +1% (-4.15ms - +4.88ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.12ms - +0.05ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-1.11ms - +0.69ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +1% (-0.11ms - +0.16ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +2% (-0.87ms - +0.92ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +4% (-0.06ms - +0.08ms)
    preact-local vs preact-main
  • todo: faster ✔ 1% - 2% (0.22ms - 0.67ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -5% - +1% (-1.44ms - +0.30ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -4% - +5% (-0.18ms - +0.25ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: faster ✔ 0% - 6% (0.00ms - 0.06ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - -0% (-0.00ms - -0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local671.99ms - 678.78ms-unsure 🔍
-1% - +1%
-4.15ms - +4.88ms
preact-main672.05ms - 678.00msunsure 🔍
-1% - +1%
-4.88ms - +4.15ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.09ms - 19.09ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-main19.09ms - 19.09msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.52ms - 16.58ms-unsure 🔍
-1% - +0%
-0.12ms - +0.05ms
preact-main16.51ms - 16.66msunsure 🔍
-0% - +1%
-0.05ms - +0.12ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.56ms - 1.57ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.57ms - 1.57msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local57.56ms - 58.72ms-unsure 🔍
-2% - +1%
-1.11ms - +0.69ms
preact-main57.66ms - 59.04msunsure 🔍
-1% - +2%
-0.69ms - +1.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.99ms - 5.34ms-unsure 🔍
-4% - +5%
-0.18ms - +0.25ms
preact-main5.00ms - 5.25msunsure 🔍
-5% - +3%
-0.25ms - +0.18ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.49ms - 16.56ms-unsure 🔍
-1% - +1%
-0.11ms - +0.16ms
preact-main16.38ms - 16.64msunsure 🔍
-1% - +1%
-0.16ms - +0.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.75ms - 3.76ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.75ms - 3.76msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5709
  • Commit: 0d68f5c

duration

VersionAvg timevs preact-localvs preact-main
preact-local54.41ms - 55.56ms-unsure 🔍
-2% - +2%
-0.87ms - +0.92ms
preact-main54.27ms - 55.65msunsure 🔍
-2% - +2%
-0.92ms - +0.87ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.02ms - 3.03ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.02ms - 3.02msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local29.21ms - 30.03ms-unsure 🔍
-0% - +3%
-0.10ms - +0.96ms
preact-main28.85ms - 29.53msunsure 🔍
-3% - +0%
-0.96ms - +0.10ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.74ms - 35.17ms-unsure 🔍
-2% - +4%
-0.73ms - +1.28ms
preact-main33.48ms - 34.89msunsure 🔍
-4% - +2%
-1.28ms - +0.73ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.89ms - 31.13ms-unsure 🔍
-3% - +2%
-0.98ms - +0.73ms
preact-main30.05ms - 31.22msunsure 🔍
-2% - +3%
-0.73ms - +0.98ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local25.71ms - 26.01ms-unsure 🔍
-2% - +1%
-0.48ms - +0.16ms
preact-main25.73ms - 26.30msunsure 🔍
-1% - +2%
-0.16ms - +0.48ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.05ms - 24.69ms-unsure 🔍
-5% - +4%
-1.13ms - +1.07ms
preact-main23.17ms - 24.63msunsure 🔍
-4% - +5%
-1.07ms - +1.13ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.50ms - 20.91ms-unsure 🔍
-1% - +2%
-0.29ms - +0.48ms
preact-main20.28ms - 20.94msunsure 🔍
-2% - +1%
-0.48ms - +0.29ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 220
  • Built by: CI #5709
  • Commit: 0d68f5c

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.89ms - 1.99ms-unsure 🔍
-3% - +4%
-0.06ms - +0.08ms
preact-main1.88ms - 1.98msunsure 🔍
-4% - +3%
-0.08ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.02ms - 1.06ms-faster ✔
0% - 6%
0.00ms - 0.06ms
preact-main1.05ms - 1.10msslower ❌
0% - 6%
0.00ms - 0.06ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.43ms - 31.74ms-faster ✔
1% - 2%
0.22ms - 0.67ms
preact-main31.87ms - 32.20msslower ❌
1% - 2%
0.22ms - 0.67ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.28ms - 1.28ms-unsure 🔍
-0% - -0%
-0.00ms - -0.00ms
preact-main1.28ms - 1.28msunsure 🔍
+0% - +0%
+0.00ms - +0.00ms
-
update10th1k
  • Browser: chrome-headless
  • Sample size: 130
  • Built by: CI #5709
  • Commit: 0d68f5c

duration

VersionAvg timevs preact-localvs preact-main
preact-local28.41ms - 29.65ms-unsure 🔍
-5% - +1%
-1.44ms - +0.30ms
preact-main28.99ms - 30.21msunsure 🔍
-1% - +5%
-0.30ms - +1.44ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.99ms - 2.99ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-main2.99ms - 3.00msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-

tachometer-reporter-action v2 for CI

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

Size Change: -39 B (-0.25%)

Total Size: 15.7 kB

📦 View Changed
Filename Size Change
dist/preact.mjs 4.97 kB -39 B (-0.78%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.mjs 3.7 kB
debug/dist/debug.mjs 3.89 kB
devtools/dist/devtools.mjs 274 B
hooks/dist/hooks.mjs 1.55 kB
jsx-runtime/dist/jsxRuntime.mjs 861 B
test-utils/dist/testUtils.mjs 473 B

compressed-size-action

@coveralls

coveralls commented Jul 18, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 98.492%. remained the same — JoviDeCroock/reduce-core-bundle-size into main

Simplify core control flow and reuse existing constants to reduce the production bundle from 4,857 to 4,814 bytes gzip while preserving behavior.
Keep createElement and cloneElement normalization together and reuse their argument counts. This reduces core from 4,814 to 4,804 bytes gzip without adding runtime work.
Restore the existing isValidElement declaration and remove the obsolete cloneElement re-export module. This leaves core at 4,806 bytes gzip while narrowing source churn.
- Guard the oldChildren lookup with ~_index: a negative array index is
  a named property access which V8 can't serve from the fast elements
  path, this made every mounted child pay a dictionary lookup.
- Compare remainingOldChildren against (matched ? 1 : 0) instead of the
  boolean so the comparison stays on the Smi fast path.
@JoviDeCroock
JoviDeCroock force-pushed the JoviDeCroock/reduce-core-bundle-size branch from b45e121 to 0d68f5c Compare July 22, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants