Getting Started
Install via npm for ESM builds, or drop a single file via CDN. Zero dependencies, works in every modern browser.
Install
bash
npm install flash.jsRequires Node 18+ for build tooling only; the library itself has no dependencies and runs in browsers without a build step.
CDN / <script>
html
<script src="https://unpkg.com/flash.js/dist/flash.min.js"></script>
<script>
F.ready(() => {
F(".button").on("click", () => F.toast("Hello!", "success"));
});
</script>Also available via jsdelivr — dist/flash.js (unminified) and dist/flash.min.js (minified, UMD). Global F and Flash are aliases.
ESM
js
import { F } from "flash.js";
F(".card").addClass("active");
F("#app").html("<h1>FLASH.js</h1>");Side-effects: false — bundlers can tree-shake unused modules. See Modules.
Subpath imports
js
import { http } from "flash.js/http"; // only fetch wrapper
import { toast } from "flash.js/ui"; // only toast
import { storage } from "flash.js/storage";First project
html — index.html
<!doctype html>
<button class="button">Click me</button>
<div class="message"></div>
<script type="module">
import { F } from "flash.js";
F(".button").on("click", () => {
F(".message").text("Hello, FLASH.js!");
});
</script>
.message — waiting
TypeScript
ts
import { F, FlashCollection } from "flash.js";
const els: FlashCollection = F(".card");
els.addClass("active").on("click", (e) => console.log(e));Types ship in flash.d.ts — include "moduleResolution": "bundler" and import as ESM.
Browser support
Evergreen browsers — Chrome/Edge/Firefox/Safari latest. Uses querySelectorAll, fetch, CustomEvent, Web Animations API, IntersectionObserver etc. No IE11.