@tim-spw/utils
v0.1.33
Published
A set of browser-native utilities providing modular, attribute-driven features for the web.
Readme
utils
A set of browser-native utilities providing modular, attribute-driven features for the web.
- Modular Loader: Features are loaded dynamically via
loader.jsusing thedata-featuresattribute. - Idempotent Initialization: All features must export an idempotent
init()function, ensuring safe repeated initialization. - Debugging: Enable namespaced logs via
data-debugorlocalStorage.setItem('utils:debug','*').
Quick Start (Declarative)
<script type="module" src="/loader.js"
data-features="video"
data-debug="loader">
</script>Programmatic bootstrapping is not required; features load via attributes only.
Note: The loader intentionally exposes no public programmatic API. Use attributes to opt‑in to features.
CDN (jsDelivr)
Version-pinned (recommended):
<script type="module"
src="https://cdn.jsdelivr.net/npm/@tim-spw/[email protected]/loader.js"
data-features="video"
data-debug="loader">
</script>Latest tag (auto-updating; not recommended for production stability):
<script type="module" src="https://cdn.jsdelivr.net/npm/@tim-spw/utils/loader.js"
data-features="video"></script>Update the @0.1.25 segment when publishing a new release; the exported VERSION constant mirrors package.json.
Publishing (CI)
Lean flow: just push to main.
- The autobump action bumps the patch version, syncs versioned constants and pinned CDN links, commits "Release vX.Y.Z [ci release]", pushes, and publishes to npm.
- Requirements: set
NPM_TOKENrepo secret with publish permission.
Debugging
Enable all namespaces:
localStorage.setItem('utils:debug','*');
// reload pageEnable specific namespaces (comma separated):
<script type="module" src="/loader.js" data-debug="loader,video"></script>