Native ES module
Bundlers resolve the bare easy-stack import normally. Native browser ESM needs an import map, but no build or transpilation step. For the normal npm layout, place the complete map before the module script:
<script type="importmap">
{
"imports": {
"easy-stack": "./node_modules/easy-stack/stack.js"
}
}
</script>
<script type="module">
import Stack from 'easy-stack';
const stack = new Stack();
stack.add(function renderNewest() {
render();
this.next();
});
</script>Map URLs are relative to the HTML document, not the importing JavaScript file. Serve the page over HTTP(S), and make sure the server exposes every mapped file under node_modules; file:// is not supported. easy-stack has zero runtime dependencies, so this is the complete map today. No dependency entry or scoped nested-dependency map applies unless a future release adds a runtime dependency.
Modern classic script
stack-vanilla.js installs globalThis.Stack for a classic script environment. It uses private class fields without module syntax.
<script src="./node_modules/easy-stack/stack-vanilla.js"></script>
<script>
var stack = new Stack();
stack.add(function newest() {
console.log('newest');
this.next();
});
</script>Use this path when an existing page expects a global constructor and targets browsers with private-field support. Use es5.js when the browser cannot parse that syntax.
ES5 compatibility script
es5.js uses ES5-era syntax and a numeric argument loop. It creates the same global Stack without the inherited-property enqueue bug in v1.
<script src="./node_modules/easy-stack/es5.js"></script>The compatibility build relies on ES5 features such as Object.defineProperties and Array.isArray. Test the exact browsers your application supports.
Serve over HTTP
Native modules need an HTTP(S) origin and a JavaScript content type. Do not treat a file:// URL as equivalent browser verification.
# From this repository
npm start
# Open the printed local URLThe repository server confines paths to the project root, emits explicit content types, rejects traversal, and powers the same examples deployed through GitHub Pages.
Next pageExamples and live demo →