MIT licensed

JS-modules

Small, dependency-free pieces for single-file browser games and apps. Copy one file, get one fix.

<script src="save-kit.js"></script>orconst SaveKit = require('./save-kit.js')
56 modules and tools0 dependenciesWebAssembly first, JS fallbackMIT

What it is and how it works

JS-modules is a set of 56 small browser libraries and tools, each solving one problem met while building LFC Foundry's apps: Apple Press, Fancy, the Banana, Pineapple Defense, Story Editor and Netflow Map.

The modules are for developers; the apps built from them need no install and no special knowledge.

Why it exists

Single-file offline apps cannot load code from a server, so any library has to be copied into the file, and its size is part of every download. These modules are plain files with no build step and no dependencies. A module is kept only if it does something the nearest open-source option does not, or does it measurably better, and its README says where the other one wins.

Where it helps

Highlights

One file each

Copy only what you need. No build step, no package tree.

Fast by default

Hot paths run in WebAssembly with SIMD, with plain JavaScript when wasm is missing.

Gives memory back

The heavy modules hand memory back after big jobs, by a trim() call or an idle timer.

Tested in three browsers

Firefox, Chromium and WebKitGTK. Every release names the versions it ran in.

Works with AI helpers

AGENTS.md, llms.txt and modules.json describe every piece for people and assistants.

Files other languages can open

lfc-pack files are read by Python and Go as well as the browser, so data packed in a page is not locked in.

Safe saves in 966 bytes

save-kit-lite keeps checked fields and a backup slot in 966 bytes minified and gzipped, for small games.

Big Excel files, faster

zip-open opens Excel files over 16 MB on the page 3 to 24% faster (cloud Firefox, Chromium, WebKitGTK), with the same results.

Numbers you can check

Every number names the browser and machine it ran on, and slower cases are stated.

Quick start

Save a game safely in three lines.

<!-- copy modules/save-kit/save-kit.js next to your page -->
<script src="save-kit.js"></script>
<script>
  var kit = SaveKit.create({ key: 'mygame', schema: { score: 'num' } });
</script>

Compared with the usual choice

lfc-pack 0.4.0 against Parquet on 260 MB of real FHIR records (140,468 rows). Measured 2026.10.31 in the cloud test browsers (Chromium 153, Firefox 158, WebKitGTK 2.52.6) on a shared 4-core machine; medians. Parquet was written natively by pyarrow 26 after a DuckDB 2.0 read of the same JSON (zstd level 3, 4 threads).

MeasureParquetlfc-pack
Pack time, one thread7.44 s2.13 to 2.69 s
Pack time, 4 helpers7.44 s1.08 to 1.56 s
File size18.74 MB8.32 MB

2.8 to 3.5 times Parquet's speed on one thread and 4.8 to 6.9 times with 4 helpers, at 44% of its size. Since this run, 0.4.4 packs FHIR 10 to 15% faster, and 0.4.6 makes the same file 7.30 MB, 39% of Parquet's size. Since 0.4.13 the library file itself is 353 KB instead of 789 KB, and 0.4.15 packs event tables 14 to 25% faster and logs 10 to 16% faster on a laptop (Firefox 160, Chromium 156), with byte-identical files.

Smaller and faster than the usual choice

Measured against the common alternative. Each chart says where it ran; both come from the module pages.

We are ahead of the nearest alternative on 23 of the 26 comparisons we have measured, and behind on 3

Times faster than the named alternative, one dot per comparison (log scale; the line is level, right is ahead).

elias-fano vs roaring-wasm, first value at or above x
38x
netflow-layers vs dagre, 300 real items (low end)
35x
lzma-decode (WebAssembly) vs LZMA-JS, real files (low end)
26x
save-kit vs idb-keyval, save
18x
graph-walk vs graphology, real purchase graph (low end)
12x
clip-writer MP4 vs mp4-muxer
6x
memory-compression vs fflate, real rows, pack (low end)
5.1x
lz4-kit compress vs browser gzip, real files (low end)
4.2x
idle-core vs break_infinity.js
3.5x
gif-writer vs gifenc, real game frames (low end)
3.3x
LFC-pack write vs gzip
3.2x
walker-sim vs a plain loop
2.9x
spotlight-tour vs driver.js, Shepherd.js, Intro.js
2.7x
text-columns vs Papa Parse, real files (low end)
2.08x
gpu-blur bytes out vs browser filter
2x
zstd-kit decompress vs fzstd, real files (low end)
1.9x
LFC-pack row reads vs Parquet readers (low end)
1.7x
LFC-pack aggregate vs DuckDB-WASM (low end)
1.5x
zip-open vs fflate, 400 real CSV files (low end)
1.3x
save-kit 16 MB load vs idb-keyval and localForage
1.3x
gpu-blur drawn canvas vs browser filter (low end)
1.2x
elias-fano default block lists vs roaring-wasm, spread-out intersect
1.1x
pad-nav vs js-spatial-navigation, WebKitGTK
1.05x
elias-fano default block lists vs roaring-wasm, decoding everything
0.77x
save-kit vs localForage localStorage driver, 20 KB load, WebKitGTK
0.65x
sprite-baker vs three.js with smooth edges
0.62x
1x10x100x1,000x

Source and notes: each dot is the headline figure from that module's page, the lowest end where it is a range; laptop runs where we have them, otherwise the three cloud browsers. One compares against a plain loop, not a rival library. The netflow-layers dot is speed only; its page has the crossings comparison. The ones behind are on their module pages with the reasons.

memory-compression makes 300,000 network links about 2.5 times smaller than msgpackr

Size of 300,000 network links, megabytes. Lower is better.

JSON text
57.3 MB
cbor-x
20.9 MB
msgpackr
20.0 MB
memory-compression
7.85 MB

Source and notes: Fast mode, restored exactly, measured on version 2.0.1 (sizes are exact byte counts). About 2.5 times smaller than msgpackr, and it unpacks as fast or faster in Chromium 155, Firefox 158, WebKitGTK 2.52.6. It loses on download size: since 2.12.0 the minified full file is 83.1 KB gzipped and the read-only file 37.1 KB, against 11 KB for msgpackr.

text-columns reads 200,000 CSV rows 3.2 times faster than Papa Parse with typed rows

Time to read 200,000 CSV rows, milliseconds. Lower is better.

Papa Parse, typed rows
166 ms
Papa Parse, arrays
86 ms
d3-dsv, arrays
80 ms
text-columns
52 ms

Source and notes: Laptop, Firefox 160, 16 cores, text-columns 0.5.0, 2026.10.30; 6 columns, 7.9 MB. Papa Parse with typed rows takes 3.2 times as long here and 7 to 12 times as long in the cloud test browsers (Firefox 158, Chromium 155, WebKitGTK 2.52.6).

The lfc-pack library file is now less than half its old size

Library file size, kilobytes, version 0.4.13 against 0.4.12. Lower is better.

lfc-pack 0.4.12
789 KB
lfc-pack 0.4.13
353 KB

Source and notes: The built-in WebAssembly programs are stored compressed and the browser unpacks them while it compiles them. Results are the same, and load to first result takes 3 to 11% less time (cloud test browsers, lfc-pack changelog).

netflow-sankey is about as fast as d3-sankey in Chromium and about 1.4 to 1.5 times faster in Firefox and WebKitGTK

Time to build the whole 1,500-item chart, milliseconds. Lower is better.

Chromium: d3-sankey
32 ms
Chromium: netflow-sankey
30 ms
Firefox: d3-sankey
29 ms
Firefox: netflow-sankey
19 ms
WebKitGTK: d3-sankey
32 ms
WebKitGTK: netflow-sankey
22 ms

Source and notes: netflow-sankey 2.7.0 against d3-sankey 0.12.3, same random data (1,500 items, 2,331 links), cloud test browsers (Chromium 155, Firefox 158, WebKitGTK 2.52.6), median of 3 runs, re-measured 2026.11.05. In Chromium the runs overlap, so it is a tie. d3-sankey is faster on small charts with default settings (100 items: 8 ms against 3.6 ms).

netflow-sankey draws the same 1,500-item chart with about a third fewer link crossings than d3-sankey

Link crossings in the finished picture. Fewer is better.

d3-sankey
95,509
netflow-sankey
60,787

Source and notes: same random 1,500-item, 2,331-link data and versions as above, cloud test browsers. Only 256 band pieces pass over a bar they do not belong to, against 1,916 for d3-sankey, and loops are drawn instead of refused.

netflow-layers draws a 1,000-item map with the fewest link crossings, in 129 ms against 2.1 s for ELK

Link crossings as drawn; fewer is better.

dagre
23,965
ELK
22,602
netflow-layers
21,812

Source and notes: Random map of 1,000 items and 1,900 links, Chromium 155; the same counts in Firefox and WebKitGTK. netflow-layers takes 129 ms, ELK 2.1 s and dagre 8.4 s. At 400 items the three are level.

Pick a piece

A small selection. The full list of 56 is in the repository README.