Commit Graph

3 Commits

Author SHA1 Message Date
Artur Pata cc5ca4b752
Script v2: Apply prettier (#5718)
* Apply prettier

* Fix issue with quotes in test setup

* Fix other issues with customSubmitHandlerStub

* Fix format with cookies fixtures
2025-09-15 11:21:27 +00:00
Karl-Aksel Puulmann 595e71a399
ScriptV2: NPM library codebase (#5459)
* Compile NPM modules into commonjs and esm modules

Note that since the module uses only vanilla es5 outside the export,
it's safe to just append to the minified output

* package.json, Typescript definition, generation for commonjs

* Scrap commonjs for the moment

Running into too big rabbit holes trying to get it off the ground

* Shared tests for npm and web

* Better way to identify npm module in fixture

* Simplify code

* Add NPM library specific tests

* Fix a flaky test

* Standardize a callsite

* npm_package standardize on

* Make legacy variant code more explicit

* Wrap code pre and post

* analyze-sizes.js should work with npm_package

* Port test changes from PR #5432

* Update outbound link feature test

* Await callInit

* Smaller npm module - mangle variables

* Clean up wrapping code

* chore: Bump tracker_script_version to 15

* Add debug messaging to expect

* Remove dead code

* Refactor, account for initialization delays in tests

* Remove needless features from compiler

As the compiler currently manages to compile everything in ~3 seconds,
the `features`/`compileIds` feature serves no more point. Scrapping it

* Re-inline readOutput

* Update tracker/test/plausible-npm.spec.js

Co-authored-by: Artur Pata <artur.pata@gmail.com>

* Remove redundant comment

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-06-04 10:47:44 +00:00
Karl-Aksel Puulmann 96abac2d4e
ScriptV2: plausible-main, script size measurements (#5375)
* analyze-sizes.js script

* Start work on plausible-main

Size changes:
```
Main variants:
|                                 | Brotli | Gzip  | Uncompressed |
| ------------------------------- | ------ | ----- | ------------ |
| plausible-main.js (new variant) | 2344B  | 2675B | 6062B        |

Important legacy variants:
|                                                                                                   | Brotli               | Gzip                 | Uncompressed          |
| ------------------------------------------------------------------------------------------------- | -------------------- | -------------------- | --------------------- |
| plausible.js                                                                                      | 1086B (-6B / -0.5%)  | 1283B (+5B / +0.4%)  | 2684B (+4B / +0.1%)   |
| plausible.hash.js                                                                                 | 1078B (+24B / +2.3%) | 1268B (+29B / +2.3%) | 2642B (+76B / +3%)    |
| plausible.pageview-props.tagged-events.js                                                         | 1846B (+57B / +3.2%) | 2158B (+63B / +3%)   | 4739B (+185B / +4.1%) |
| plausible.file-downloads.hash.pageview-props.revenue.js                                           | 1669B (+62B / +3.9%) | 1958B (+54B / +2.8%) | 4097B (+175B / +4.5%) |
| plausible.compat.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js | 2286B (+81B / +3.7%) | 2692B (+84B / +3.2%) | 5978B (+280B / +4.9%) |

Summary:
|                                                                                                                     | Brotli               | Gzip                 | Uncompressed            |
| ------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------- | ----------------------- |
| Largest variant (plausible.compat.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js) | 2286B (+81B / +3.7%) | 2692B (+84B / +3.2%) | 5978B (+280B / +4.9%)   |
| Max change (plausible.exclusions.hash.local.manual.outbound-links.pageview-props.js)                                | 1460B (+80B / +5.8%) | 1755B (+83B / +5%)   | 3557B (+241B / +7.3%)   |
| Min change (plausible.js)                                                                                           | 1086B (-6B / -0.5%)  | 1283B (+5B / +0.4%)  | 2684B (+4B / +0.1%)     |
| Median change                                                                                                       | 1723B (+65B / +3.9%) | 2037B (+70B / +3.6%) | 4335B (+220.5B / +5.3%) |
```

* Janky conditionals for COMPILE_CONFIG

Results in no size increase for historical scripts:

Main variants:
|                                 | Brotli | Gzip  | Uncompressed |
| ------------------------------- | ------ | ----- | ------------ |
| plausible-main.js (new variant) | 2339B  | 2672B | 6058B        |

Important legacy variants:
|                                                                                                   | Brotli          | Gzip                | Uncompressed    |
| ------------------------------------------------------------------------------------------------- | --------------- | ------------------- | --------------- |
| plausible.js                                                                                      | 1092B (0B / 0%) | 1280B (+2B / +0.2%) | 2680B (0B / 0%) |
| plausible.hash.js                                                                                 | 1054B (0B / 0%) | 1241B (+2B / +0.2%) | 2566B (0B / 0%) |
| plausible.pageview-props.tagged-events.js                                                         | 1789B (0B / 0%) | 2097B (+2B / +0.1%) | 4554B (0B / 0%) |
| plausible.file-downloads.hash.pageview-props.revenue.js                                           | 1607B (0B / 0%) | 1906B (+2B / +0.1%) | 3922B (0B / 0%) |
| plausible.compat.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js | 2205B (0B / 0%) | 2610B (+2B / +0.1%) | 5698B (0B / 0%) |

Summary:
|                                                                                                                     | Brotli                   | Gzip                     | Uncompressed             |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------ | ------------------------ |
| Largest variant (plausible.compat.exclusions.file-downloads.outbound-links.pageview-props.revenue.tagged-events.js) | 2205B (0B / 0%)          | 2610B (+2B / +0.1%)      | 5698B (0B / 0%)          |
| Max change (plausible.js)                                                                                           | 1092B (0B / 0%)          | 1280B (+2B / +0.2%)      | 2680B (0B / 0%)          |
| Median change                                                                                                       | 1655B (0B / 0%)          | 1969B (+2B / +0.1%)      | 4116B (0B / 0%)          |

* plausible-main: no COMPILE_EXCLUSIONS

Size change from this:
|                   | Brotli              | Gzip                  | Uncompressed          |
| ----------------- | ------------------- | --------------------- | --------------------- |
| plausible-main.js | 2223B (-116B / -5%) | 2533B (-139B / -5.2%) | 5710B (-348B / -5.7%) |

* Rework server.js to be less compiler-aware

* Add first test for plausible-main.js

* Tests for plausible-main variant

* Remove report-sizes.js

* Tracker - report size changes in a comment

* Update summary notes

* Handle outbound links not being captured by network tab in webkit

See: https://3.basecamp.com/5308029/buckets/39034214/card_tables/cards/8429433464

* Solve a TODO

* Sign in comment

* Update pin

* Mock file downloads

* Update base branch

* Pin add-and-commit as per cenk request

* Use bot for checkout

* Attempt to reduce permissions

* Smaller fetch depth

* Fix rebase
2025-05-12 06:55:54 +00:00