Vanilla ES6+ JavaScript Modules — Straight From a CDN

A set of small, dependency-free JS modules for static sites — DOM helpers, fetch wrappers, cookies, URL utilities, and a WhatsApp QR login flow. Import what you need directly from jsDelivr; no npm install, no bundler.

latest version jsDelivr hits license

What's Actually In It

Zero Build, Zero Install

Import modules straight from jsDelivr's CDN with a <script type="module"> tag. No npm install, no bundler config, no build step.

Fetch Wrappers, Not a Framework

getJSON, postJSON, putJSON, deleteJSON — thin wrappers over the native Fetch API with a consistent {status, data} callback.

DOM Helpers Without the Boilerplate

onClick, setInner, getValue, serializeForm, show/hide — skip repetitive document.getElementById calls. Pair with debounce.js for search-as-you-type.

WhatsApp QR + OTP Login

auth.js and stp.js give you a ready-made WhatsAuth QR-code and OTP login flow, including Google Sign-In.

Cookies, Storage, URLs & Validation

cookie.js, storage.js, url.js, and validate.js cover session cookies, localStorage/sessionStorage (with optional expiry), query strings, and input sanitization.

Import Only What You Use

Every module is a separate CDN file — .../lib@version/cookie.js — so your page only loads the code it actually needs.

Notifications, No Dependency

toast.js shows dismissable notifications with zero external libraries — an alternative to pulling in SweetAlert2 just for a message.

Read GeoJSON

geo.js loads GeoJSON from a URL or a local file, validates it, and always hands back a FeatureCollection — plus getBBox, getCenter, and getPropertyKeys for feeding a map or a table.

Quick Start Example

Get started with CrootJS in just a few lines of code. Import from CDN and start building dynamic websites immediately.

main.js
// Import CrootJS functions from CDN
import { setInner, onClick, getValue }
from "https://cdn.jsdelivr.net/gh/crootjs/lib@0.0.13/element.min.js";
import { postJSON } from "https://cdn.jsdelivr.net/gh/crootjs/lib@0.0.13/api.min.js";

// Configure backend URL
const urlBackend = "https://api.example.com";

// Handle login button click
onClick("loginBtn", () => {
  // Get form values
  const email = getValue("email");
  const password = getValue("password");

  // Send login request
  postJSON(`${urlBackend}/login`, { email, password }, (response) => {
    // Handle response
    if (response.status === 200) {
      setInner("demo", "Login successful!");
    }
  });
});

Building With an AI Coding Agent?

CrootJS requires separating HTML, CSS, and JS into their own files, with JS loaded as type="module" — no inline <script>/<style>, no onclick. Drop CLAUDE.md into your project root so Claude Code (or any agent that reads a root instructions file) follows this automatically.

terminal
curl -o CLAUDE.md https://raw.githubusercontent.com/crootjs/lib/main/CLAUDE.md

See CrootJS in Action

Explore real-world examples and templates built with CrootJS. Fork the examples repo on GitHub to get started quickly.

Form Login

A cookie-based login form example — checks the session cookie and redirects automatically.

View Demo →

Set Inner Element

A minimal example showing how to set element text content with CrootJS's setInner helper.

View Demo →

SVG Canvas Demo

Render dynamic text onto an HTML canvas with auto-fitting font size, powered by CrootJS.

View Demo →

SweetAlert Dialogs

Alerts, delete confirmation, a validated form inside a dialog, and a loading state around getJSON.

View Demo →

GeoJSON on a Map

Load GeoJSON from a URL or a local file with geo.js, draw it on a Leaflet map, and list its properties in a table.

View Demo →

API Documentation

Interactive API documentation powered by Swagger UI.

View Demo →

404 Error Page

A playful, animated 404 error page example.

View Demo →

Performance Benchmark

See how CrootJS compares to other frameworks in terms of performance and bundle size.

View Benchmark →

Start Using CrootJS

Browse the per-module docs, check the source, or fork one of the working examples.