Classic Scripts (No Bundler)
dimui, dimurl, and dim-boilerplate ship as plain .js files with no app-side transpile. Dim loads from the GitHub Pages CDN as a classic IIFE (window.Dim). A tiny BP registry wires modules together.
Load Dim
<script
src="https://positive-intentions.github.io/dim/lib/dim.global.js"
></script>
<!-- WASM: .../dim.wasm.global.js -->
Choose runtime with ?impl=js (default) or ?impl=wasm. Apps often persist the choice in localStorage.
While iterating on Dim itself, point at a local Pages tree:
?dimLib=http://127.0.0.1:8765/lib/
window.Dim
After the IIFE loads, APIs are on the global:
const { define, html, useState, useStore } = Dim;
define({
tag: "demo-counter",
component: (props, { html, useState }) => {
const [count, setCount] = useState(0);
return html`
<button @click="${() => setCount(count + 1)}">
Count: ${count}
</button>
`;
},
});
Hooks usually come from the second argument of the component (injected by define). That is the supported pattern for CDN apps.
BP.module / BP.require
runtime.js exposes globalThis.BP:
BP.module("notes/lib/note-filters", [], function () {
return {
filterNotes(notes, query) {
/* ... */
},
};
});
const { filterNotes } = BP.require("notes/lib/note-filters");
dimui components register as BP.module("dimui/…", deps, factory) and call window.Dim inside the factory. Apps load them as classic <script src> URLs (or via an import map / loader in runtime.js).
Four-piece stack
| Piece | Repo | Job |
|---|---|---|
| Framework | dim | define, html, hooks → CDN IIFE |
| Shared UI | dimui | Atoms/kits as unbundled scripts |
| Hash router | dimurl | <dimurl-router> / <dimurl-route> (+ hash helpers) for Pages / index.html |
| App | dim-boilerplate | Your pure JS + vault / pages |
Local atom files in the boilerplate are often proxies that re-export remote dimui modules so PWA precache lists and tests stay stable.
Query vs hash: runtime flags stay on the query string (?impl=, ?dimuiSrc=, ?dimurlSrc=, ?dimLib=). App screens live in the hash (#/note/:id) so deep links work without server rewrites.
HTTP required
Browsers need a real origin for multi-script pages and CDN loads. Serve the app:
python3 -m http.server 4173
file:// will not work reliably.
Related
- dimui
- dimurl
- dim-boilerplate
- JS vs WASM
- Unit tests — same classic-script constraint for tests