This project uses CrootJS — vanilla ES6+ JavaScript modules imported straight from jsDelivr, no npm, no bundler. Follow these rules whenever you write, edit, or generate code in this project.
<style> blocks. CSS goes in its own .css file, linked with <link rel="stylesheet" href="...">.<script> blocks with logic. JS goes in its own .js file.style="..." attributes. Use a class defined in the CSS file instead.onclick, onchange, oninput, etc). Attach listeners in JS with addEventListener, or with CrootJS’s own helpers (onClick, onChange, onInput from element.js).<script type="module" src="script.js"></script> — never a plain classic script with inline logic.Exception: a third-party library’s own CDN <script src="..."> tag is fine — that’s an external dependency, not inline application code.
Exception: integrity.js, which installs the import map with SRI hashes (see Importing CrootJS), is a classic <script src="integrity.js"></script> placed first in <head>: Firefox ignores an import map added after module loading started. It holds only that import map.
api.js requests and uploads, element.js DOM helpers, form.js validation messages, router.js page routing, table.js data tables, chart.js charts, markdown.js Markdown, qr.js QR codes, openapi.js API documentation from an OpenAPI spec, map.js maps, model3d.js 3D, toast.js notifications, croot.css + icons.css styling and icons), and don’t add libraries that duplicate it (Leaflet, Three.js, axios, jQuery, DataTables, Chart.js, marked, Swagger UI, js-yaml, Bootstrap/Bulma, icon fonts).TODO stubs, or files that aren’t needed.api.js reports network failure as status: 0); no try/catch that swallows errors.<button> for buttons, <label> for inputs, keyboard- and phone-friendly; no decoration nobody asked for.crootjs.d.ts next to your jsconfig.json.Pages must not look AI-generated. Start from croot.css (+ optional ui.css components, a themes.css theme, icons.css) and the page patterns at https://croot.js.org/examples/pola/, then change only what the product needs.
backdrop-filter, glows, blobs, hover lifts, scroll animations.icons.css next to text, or a plain list/table.--croot-radius.--croot-accent), used sparingly. Never color as the only signal: add text (“Naik 4%”, “Gagal”).Every site (the folder with the site’s index.html, e.g. the repo root on GitHub Pages) must also have a 404.html in the same folder: separate CSS (croot.css is fine), absolute paths (/, /style.css) because it is shown for wrong addresses in every subfolder, <meta name="robots" content="noindex">, a plain message and links to the likely destinations. Example: https://croot.js.org/examples/pola/kosong-404/404.html
https://cdn.jsdelivr.net/gh/crootjs/lib@<version>/<module>.js. Never @latest in committed code.cookie.js, api.js), not the whole library..min.js variant instead of .js: https://cdn.jsdelivr.net/gh/crootjs/lib@<version>/cookie.min.js. Use the unminified .js only when actively reading/debugging the source. Never mix .js and .min.js on one page (all imports either .min.js or .js, same version): they are different module URLs, so modules imported by both get loaded twice with separate state (e.g. a 3D viewer created through mapmodel.min.js is unknown to model3d.js). Since 0.0.38 release tags ship their own .min.js whose relative imports point to .min.js siblings. Pin to a tag, not a commit SHA from main. Add <link rel="modulepreload"> in <head> for each imported CrootJS module and the modules it imports (list: https://croot.js.org/docs/#memuat-lebih-cepat-dengan-modulepreload), so they download in parallel.integrity.json. integrity on modulepreload is enforced only by Chromium, so also list every imported module and its dependencies in an import map integrity key installed by integrity.js, and put the same hash on the modulepreload lines. Bump versions and hashes together with python3 bump-pins.py <version|latest> [folder] (https://raw.githubusercontent.com/crootjs/lib/main/tools/bump-pins.py), never by hand. Details: https://croot.js.org/docs/en/#locking-file-contents-with-integrity-sriapi.js callback functions are NOT (url, ..., responseFunction) uniformly — check the exact parameter position per function (getJSON(url, responseFunction, tokenkey?, tokenvalue?) vs postJSON(url, data, responseFunction, tokenkey?, tokenvalue?)) before writing a call. getJSON/postJSON/putJSON/deleteJSON also return a Promise of the same { status, data }, so responseFunction may be null with await; the Promise never rejects (network failure = status: 0, with error = "timeout"/"offline"/"network"). Since 0.0.29 the argument after responseFunction may instead be an options object { headers, timeout, cache: { key, ttl } }, and results also carry headers (response Headers) and cached. ttl is in seconds and only ttl saves requests (a 304 still counts against API quotas). Since 0.0.35 cache also takes staleIfError: true (stored data with stale: true and, since 0.0.37, staleReason when the request fails) and select: data => subset (trims what is stored and returned; a throwing select gives error: "select"). Since 0.0.37 the callback always runs asynchronously, also on a cache hit. Since 0.0.30 there is also signal (AbortSignal; error: "abort"), and file uploads/downloads should use uploadFile(url, inputIdOrFile, responseFunction, { field, data, headers, onProgress }) / downloadFile(url, responseFunction, { fileName }), which return the same result shape.websocket.js’s openWebSocketSetId is Promise-based (asynchronous) — it does not return a WebSocket synchronously.