analytics icon indicating copy to clipboard operation
analytics copied to clipboard

Script v2: Test esbuild

Open apata opened this issue 7 months ago • 1 comments

Changes

Since one of the drawbacks with adding a bundler was having an additional dependency, this PR tests bundling and minifying with the tool that we already have, esbuild, replacing both swc and rollup.

Esbuild can also replace chokidar since it has a watch mode, but I didn't bother to go further after seeing the size increase.

Esbuild would also allow us to write the modules in typescript.

Tests

  • [ ] Automated tests have been added
  • [ ] This PR does not require tests

Changelog

  • [ ] Entry has been added to changelog
  • [ ] This PR does not make a user-facing change

Documentation

  • [ ] Docs have been updated
  • [ ] This change does not need a documentation update

Dark mode

  • [ ] The UI has been tested both in dark and light mode
  • [ ] This PR does not change the UI

apata avatar Jun 03 '25 07:06 apata

Analyzed 1025 tracker script variants for size changes. The following tables summarize the results, with comparison with the baseline version in parentheses.

Main variants:

Brotli Gzip Uncompressed
plausible-web.js 2426B (+144B / +6.3%) 2770B (+159B / +6.1%) 6424B (+394B / +6.5%)

Important legacy variants:

Brotli Gzip Uncompressed
plausible.js 1249B (+133B / +11.9%) 1439B (+142B / +10.9%) 3129B (+398B / +14.6%)
plausible.hash.js 1231B (+147B / +13.6%) 1424B (+156B / +12.3%) 3056B (+433B / +16.5%)
plausible.pageview-props.tagged-events.js 2005B (+181B / +9.9%) 2314B (+203B / +9.6%) 5155B (+492B / +10.6%)
plausible.file-downloads.hash.pageview-props.revenue.js 1817B (+179B / +10.9%) 2113B (+185B / +9.6%) 4467B (+462B / +11.5%)
plausible.compat.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js 2397B (+173B / +7.8%) 2817B (+198B / +7.6%) 6232B (+433B / +7.5%)

Summary:

Brotli Gzip Uncompressed
Largest variant (plausible.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js) 2401B (+175B / +7.9%) 2797B (+197B / +7.6%) 6212B (+459B / +8%)
Max change (plausible.hash.local.js) 1121B (+169B / +17.8%) 1301B (+168B / +14.8%) 2814B (+460B / +19.5%)
Min change (plausible-web.js) 2426B (+144B / +6.3%) 2770B (+159B / +6.1%) 6424B (+394B / +6.5%)
Median change 1850B (+174B / +10.4%) 2164B (+186B / +9.3%) 4637B (+433B / +10.6%)

In total, 1025 variants brotli size increased and 0 variants brotli size decreased.

github-actions[bot] avatar Jun 03 '25 07:06 github-actions[bot]