Quick Start
Fastjs supports several ways to be loaded — pick the one that fits your project.
With Bundler Recommended
Am I using a bundler?
Common bundlers include vite, webpack, rollup, and esbuild-based tools.
Why is the bundler build recommended?
The bundler build keeps process.env.NODE_ENV checks in place, so your bundler can dead-code-eliminate the development-only warnings in production. It is also fully tree-shakeable.
The bundler build keeps your final bundle small and lets you import only the helpers you need.
Create a new project
Fastjs CLI is archived
The official create-fastjs CLI was archived on Dec 22, 2023 and is no longer maintained. Use Vite (below) to scaffold a project and add jsfast manually.
Fastjs works great with vite:
npm create vite@latest fastjs-projectyarn create vite@latest fastjs-projectpnpm create vite@latest fastjs-projectbun create vite@latest fastjs-projectInstall Fastjs
cd fastjs-project
npm i jsfastcd fastjs-project
yarn add jsfastcd fastjs-project
pnpm add jsfastcd fastjs-project
bun add jsfastUsage
Open src/main.js and try the example:
import { date } from "jsfast";
console.log(date.string()); // e.g. "2025-06-19 09:32:14"A couple more one-liners to taste what's available:
import { dom, request, cookie, rand, uuid } from "jsfast";
dom("body").addClass("ready").text("Hello Fastjs!");
request.get("/api/posts").then((data) => console.log(data));
cookie.set("token", "abc", { maxAge: 3600, sameSite: "Lax" });
console.log(rand(0, 9), uuid());With CDN
Drop a single <script> to expose the fastjs global.
Usage
<script src="https://cdn.jsdelivr.net/npm/jsfast/dist/fastjs.global.js"></script>
<!-- or -->
<script src="https://unpkg.com/jsfast/dist/fastjs.global.js"></script>console.log(fastjs.date.string());
fastjs.dom("body").text("Hello!");Prefer to skip the namespace:
const { date, dom, cookie } = fastjs;For production, use the minified, development-stripped build:
<script src="https://cdn.jsdelivr.net/npm/jsfast/dist/fastjs.global.prod.js"></script>With Node.js
Production environment
Fastjs ships separate development and production builds. The production build automatically kicks in when NODE_ENV === "production". Check the variable if you do not see the speed/size you expect.
Fastjs requires Node.js ≥ 18 (for the global fetch, AbortController, and AbortSignal.timeout).
Install
npm i jsfastUsage
// ESM
import { date, request, uuid } from "jsfast";
// CJS
const { date, request, uuid } = require("jsfast");
console.log(date.string(), uuid());The browser-only modules (
dom,cookie,utils.copy) degrade safely in Node — reads returnnull/false, writes are no-ops and a warning is logged in development mode.
With Direct Import
Use the native ESM build directly in the browser, no bundler required.
Usage
<script type="module">
import { date } from "https://cdn.jsdelivr.net/npm/jsfast/dist/fastjs.esm-browser.js";
// or production:
// import { date } from "https://cdn.jsdelivr.net/npm/jsfast/dist/fastjs.esm-browser.prod.js";
console.log(date.string());
</script>