Migration from jQuery
FLASH.js keeps the DX you love — $(".card").addClass("active") → F(".card").addClass("active") — but embraces the modern platform.
Philosophy: No claim of 100% compatibility. FLASH.js intentionally diverges where the platform now has a better primitive (e.g.,
fetch over $.ajax).Side-by-side
| jQuery | FLASH.js |
|---|---|
$(selector) | F(selector) — Flash is alias; F is primary |
$(".card").addClass("a") | F(".card").addClass("a") |
$el.html() / text() / val() | F(el).html() / text() / val() |
$el.attr(k,v) / removeAttr | F(el).attr(k,v) / removeAttr |
$el.on("click", fn) | F(el).on("click", fn) |
$(document).on("click",".btn", fn) | F(document).on("click",".btn", fn) |
$el.trigger("evt") | F(el).trigger("evt", detail) |
$el.animate(props, opts) — jQuery FX | F(el).animate(keyframes, opts) — Web Animations API |
$.ajax({ url, method }) | await F.http.get("/api") / F.http.json() / F.http.request() |
localStorage manual JSON | F.storage.set/get/has — JSON auto |
Key differences
- ESM:
import { F } from "flash.js"instead of global$. UMD global still available asF/Flashfor migration. - Fetch:
F.httpthrows on non-2xx; handle viacatchanderror.status— nosuccess/errorcallbacks. - Animation: Keyframes use Web Animations API syntax
{ opacity: [0,1] }or arrays; always returnsPromise. - No Sizzle: selectors are native
querySelectorAll— no jQuery custom pseudos. - Collection vs jQuery object: FLASH's
Collectionis iterable and array-like; useget(),each,map,filter.
ESM & tree-shaking
js
// Before
import $ from "jquery";
$(".card").addClass("active");
// After — ESM + tree-shaking
import { F } from "flash.js";
F(".card").addClass("active");
// Only what you use
import { http } from "flash.js/http";Compatibility note
FLASH.js is not a drop-in jQuery shim. Porting is usually search-and-replace for DOM/events, but HTTP and animation need small rewrites to modern APIs. The docs' API reference is exactly the implemented surface — no hidden shims.