posthog-js 1.418.10 · LilScript subset · @itslil/posthog-js
Capture
kernel.
This is not PostHog and not the published posthog-js browser bundle.
It is thirteen modules from posthog-js@1.418.10 — UUID, feature-flag
utils, cookie identity, request routing, token and bucketed rate limits, queue
batching, bot detection, and the portable string / number / type / JSON / URL
helpers — rewritten in LilScript. Five independent subpaths add surveys,
error tracking, pure OTLP helpers, the complete autocapture utility module,
and a session-replay network / buffer core without pulling them into the root
kernel. The client class, active recorder, and network transport remain absent
from the root package. Every number on this page
compares that same official kernel, then Vite 8 Oxc, Terser, and esbuild, with
the settings named on each row. The headline is the direct Brotli-scored
compiler artifact. The npm ESM adds its license banner and is reported
separately; gzip and raw each have their own compile.
npm install @itslil/posthog-js
Official rows are one kernel file, then Oxc, Terser, or esbuild, measured three ways.
LilScript searches a different artifact for each cost_model, so the gzip
and raw numbers come from those compiles. The npm ESM adds a 91-byte raw license
banner, so its packaged size is a separate row rather than compiler credit.
Brotli is still the headline. The published PostHog IIFE is not a lane.
If LilScript is larger, the scoreboard says so.
What is actually here
A kernel,
not the SDK.
The official side is extracted from posthog-js@1.418.10 commit
9b2a1b18. The legacy kernel fixture lives in official/;
the five pack baselines below bundle the untouched pinned git submodule directly.
LilScript implements the same named functions. Differential tests assert matching
outputs, object shapes, edge cases, and observable mutation.
| Module | Official source | Kept | Left out |
|---|---|---|---|
| UUID | packages/core/src/vendor/uuidv7.ts | uuidv7, uuidv4, parse, fields, hex | — |
| Flags | packages/core/src/featureFlagUtils.ts | normalize, values, payloads, minimize | flag evaluation against a PostHog instance |
| Cookies | packages/core/src/cookie.ts | name, serialize, parse, consent, opt-out | document.cookie / persistence adapters |
| Router | packages/browser/src/utils/request-router.ts | api / flags / ui hosts, region, endpointFor | RequestRouter class, rewriteRequestPath |
| Rate limit | packages/browser/src/rate-limiter.ts | token-bucket context | persistence, $$client_ingestion_warning |
| Queue | packages/browser/src/request-queue.ts | flush clamp, format, offsets, unload sort | sendBeacon, timers, transport |
| Bot | packages/core/src/utils/bot-detection.ts | DEFAULT_BLOCKED_UA_STRS, isBlockedUA | navigator / UA-CH isLikelyBot |
| Strings | packages/core/src/utils/string-utils.ts | includes, trim, strip $, person hash | safeJsonStringify |
| Numbers | packages/core/src/utils/number-utils.ts | clamp, remote-config, sample rate | — |
| Types | packages/core/src/utils/type-utils.ts | empty/primitive/builtin, yes/no-like, unsafe events | DOM FormData / File / Event |
| JSON | packages/core/src/utils/json-utils.ts | sanitizeString | toJsonSafeValue |
| URL | packages/core/src/utils/index.ts | removeTrailingSlash, stripUrlHash | retries, timestamps |
| Bucketed limiter | packages/core/src/utils/bucketed-rate-limiter.ts | config resolve, consume | class wrapper, logger callback |
The larger compression showcase
Pick a module.
See its receipts.
These are separate package subpaths, not additions to the capture-kernel lane.
The official side is bundled straight from the read-only posthog-js
submodule at 9b2a1b18. No upstream TypeScript or JavaScript is edited,
and no algorithm is replaced. Each LilScript artifact is differential-tested
against that exact original before it is measured. Use the tabs to switch the
full raw, gzip, and Brotli lane table; the URL keeps the selected module.
| Selected module lane | Raw | gzip-9 | Brotli-11 | vs Oxc · Brotli |
|---|
The compiled runtime, in the browser
Live
kernel.
Left is a JSON request. Right is UUID, cookie, flags, routing, rate-limit,
queue, bot, and helper output from @itslil/posthog-js or the
official posthog-js@1.418.10 kernel — the same cut used for size.
The receipts
Raw, gzip,
and Brotli.
Official 1.418.10 kernel, then Vite 8 Oxc (mangle on/off), Terser
(3-pass mangle on/off, and 1-pass mangle on), and esbuild
(esnext and es2018). LilScript is not
post-minified. Each codec below uses the LilScript compile scored
for that codec (cost_model = raw | gzip | brotli).
The direct compiler artifacts exclude package metadata. The npm ESM
wraps the Brotli compile with a license banner and has its own row.
Closed LilScript uses extern_fields = false.
Brotli-11
The LilScript compiler row is cost_model = brotli; the packaged ESM and its license banner are shown separately.
| Lane | Brotli-11 | vs Oxc |
|---|
gzip-9
LilScript row is a separate compile: cost_model = gzip.
| Lane | gzip-9 | vs Oxc |
|---|
Raw
LilScript row is a separate compile: cost_model = raw.
| Lane | Raw | vs Oxc |
|---|
All three, verified objective artifacts
Official rows are one file measured three ways. The LilScript library row takes raw from the raw compile, gzip from the gzip compile, and Brotli from the Brotli compile. Raw and gzip retain the previous verified snapshot because this update intentionally did not launch more exhaustive builds.
| Lane | Raw | gzip-9 | Brotli-11 | Brotli vs Oxc |
|---|
Why the kernel stays separate. The published posthog-js IIFE
still contains autocapture, replay, surveys, and the client class. Putting
that file on one side and this kernel on the other is not a comparison.
The fair fight is the 1.418.10 kernel in official/, then the
same Oxc, Terser, and esbuild work the JS ecosystem actually ships. Surveys,
error tracking, OTLP, autocapture, and replay core have their own tabbed receipts
above, so their larger graphs never distort this kernel table. Closed
LilScript is the other honest comparison: public JS keys mangle.
Losses stay on the page.
Zero runtime dependencies
Install the
current port.
npm install @itslil/posthog-js