Tiny JS¶
Frontend libraries that fit into 2 kB with dependencies.
Source
79 resources imported from thoughtspile/awesome-tiny-js, dedicated to the public domain (CC0 / Unlicense). Thanks to its maintainers and contributors. Part of the KEEBOX Library · Category: Front-End Development.
UI Frameworks¶
- preact - React-like API (pre-hooks). Cool ecosystem of similarly tiny tools and components. Highly recommended.
- hyperapp - vDOM framework with pure JS syntax and immutable state,
- redom - Hyperapp-style templates with imperative event listeners and updates,
- fre - React-like library with hooks and concurrency,
- van - vDOM-based framework optimized for no-build setups,
- superfine - Hyperapp with state & effect hooks removed,
- arrowjs - Tagged templates + reactive data,
- umbrella - jQuery-style DOM manipulation library,
Event Emitters¶
- mitt - Plain event emitter that I use on most projects,
- nanoevents - Nicer unsubscribe API, but no
*event, - onfire.js - Also has
.oncemethod,
State Managers¶
- zustand - Simple stores with pleasant actions and selectors. Vanilla , React
- nanostores - Modular store with good tree-shaking support, vanilla, + React extra. Supports all the top frameworks.
- exome - Atomic stores with lots of framework connectors, + React extra. Supports all the top frameworks.
- storeon - Minimal redux-styled store with lots of framework connectors, . React extra + Vue, Svelte, Angular.
- unistore - Centralized store with actions, + React
- teaful - Store with useState-like API, , including React / preact connector.
Signals¶
- @preact/signals - The OG signals from preact core, with react integration.
- usignal - A smaller signal implementation,
- hyperactiv - 4 functions to make objects observable and listen to changes,
- flimsy - Signals from Solid (it almost fit into UI frameworks category itself). Author warning: it's probably buggy.
Reactive Programming¶
- flyd - Rx-styled event streams,
- callbag-basics - Rx-style event streams,
Routers and URL Utils¶
- wouter - Declarative router for React / preact, , also available as a standalone hook:
- @nanostores/router - Routes as a nanostores store (framework-agnostic),
- navaid - History-based observable router,
- matchit - Route parser and matcher in
- regexparam - Convert path to regexp in
- qss - Parse querystrings in . Not sure you need it, URL API support is good.
API Layer¶
- redaxios - Drop-in axios replacement for modern browsers,
- wretch - Chainable API with error processing and lots of extra plugins,
- gretchen - Chainable API with type-safe errors,
- unfetch - Loose fetch polyfill,
I18N¶
- @nanostores/i18n - Detect locale, load dictionaries, format dates / numbers, including nanostores.
- eo-locale - Interpolation and dates / numbers, , or with react bindings.
- rosetta - Bare-bones template strings (
{ {hello}}, { {username}}) and custom functions for everyting else, - lingui - Small core with template strings,
Dates and Time¶
- date-fns - Not tiny as a whole, but most functions are under 1 kB each (format and parse are quite heavy).
- dayjs - Almost moment.js-compatible API, covers most use cases,
- tinytime - Simple date / time formatter:
{h}:{mm} -> 9:33, - tinydate - Date / time formatter, only supports padded numeric output (
September -> 09), - time-stamp - More of the same,
- ms - Parse & format ms durations, e.g.
"1m" 60000, - timeago.js - Format dates into stuff like X minutes ago or in X hours,
- fromnow - More of the same,
Generic Utilities¶
- remeda - 90 tree-shakable helpers (list).
- rambda - 187 tree-shakable helpers (list).
- just - 82 helpers in separate packages (list).
- @fxts/core - 96 tree-shakable helpers. Lazy evaluation support.
Validation¶
- v8n - zod-style API with fine-grained checks:
v8n().string().minLength(5).first("H").last("o"). No tree shaking, - banditypes - The smallest validation library:
- superstruct - The most popular modular validation library with good tree-shaking,
- valibot - Another modular validation library,
- deep-waters - Composable functional validators, .
Unique ID Generation¶
- @lukeed/uuid - Real UUIDs,
- nanoid - Random IDs with larger alphabet,
- uid - More of the same,
- hexoid - Hexadecimal IDs,
Colors¶
- colord - Manipulate colors and convert between spaces, . Extra features come as plugins, 150b to 1.5 kB each.
- colr - More of the same,
- polychrome - More of the same,
- randomcolor - Attractive random colors with configuration.
Touch Gestures¶
- alloyfinger - Pan, swipe, tap, doubletap, longpress, and pinch / rotate. My personal favorite. .
- tinygesture - Configurable pan, swipe, tap, doubletap, longpress. .
- pointer-tracker - Unified interface for mouse, touch and pointer events,
- detect-it - Detect present and primary input method (touch / mouse) and supported events,
Text Search¶
- js-search - Feature-rich and customizable: multi-field indices, stop words, custom stemmers and tokenizers.
- ndx - Similar to js-search, differs in ranking and is less strict for multi-word queries (compare). Supports field weights.
- wade - Also similar, (compare)
- libsearch - Index-free search (slower, but easier to use) with sane ordering
- stemmer -
- porter-stemmer -
Fuzzy search¶
- fuzzy - Index-free, can highlight matches.
- fuzzy-search - With stateful index.
- fzy.js - Matches one string at a time, tree-shakeable scores and match highlighting. total, or ~150 bytes for
hasMatchonly. - fuzzysearch - One string at a time, does not compute score / rank.
- liquidmetal - Quicksilver algorithm, prioritizes matches at start of word for command abbreviations (e.g.
gp->git push). One string at a time. - quick-score - Another quicksilver-based lib, tweaked for long strings. Built-in list filtering and sorting, or 1.2 kB for single-string scoring.
- fuzzyset - Find misspellings, e.g. missipissi -> Missisipi, Commercial usage costs $42.