npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

imm-dom

v0.3.8

Published

Immediate-mode DOM tools

Downloads

188

Readme

Immediate-Mode DOM Tools

Lightweight tooling around DOM creation. Designed to be embedded piecewise in self-contained Web Components.

I love virtual DOM libraries like superfine, preact, and inferno. But not all creations need the efficient updating logic. Creations like self-sufficient Web Components, where every byte of superfluous logic is wasted.

The imm-dom library enables concise expression of DOM creation, while never setting innerHTML with uncontrolled content. Elements are created using createElement() or createElementNS(). Strings become Text nodes via createTextNode() or elem.append(). Attributes are set using elem.setAttribute(). DOM injection is protected against, in conjunction with caution and expertise, to provide tools for dynamic content.

Demo

See the mini demo and the demo's index.html source.

API

imm-dom provdes layers of DOM tools:

  • Creating new DOM elements, both HTML and SVG
  • Manipulating (existing) DOM elements
  • Defining Web Components
  • Misc utilities: promises, deferreds, render animation frames, etc.

Read more in docs/README.md

Immediate Custom Element Web Componet API:

<section>
  <imm-demo-cdn data-demo=yes kind=awesome title='my demo title'>
    some body text for the CDN demo
  </imm-demo-cdn>

  <script type=module>
    import {imm_html as h, ImmElem} from 'https://cdn.jsdelivr.net/npm/imm-dom@latest/esm/index.js'

    ImmElem.elem('imm-demo-cdn', ns =>
      h.article(
        {class: ns.kind},
        h.h3(`${ns.title}`),
        h.slot('Body text Slot')) )
  </script>
</section>

Inspired by:

Immediate DOM API:

imm_html.article({class: 'awesome'},
  imm_html.h3('my demo title'),
  'some body text')

// or

tag('article', {class: 'awesome'},
  tag('h3', 'my demo title'),
  'some body text')

Inspired by:

Immediate Template API:

imm_tmpl`
  <article ${ {class: 'awesome'} }>
    <h3>${ 'my demo title' }</h3>
    ${ 'some body text' }
  </article>`

Inspired by:

Immediate requestAnimationFrame API

  • imm_raf() returns a promise for the next requestAnimationFrame tick.
  • ImmRAF is like ImmElem using requestAnimationFrame to decouple attribute updates from rendering.

Size Cost in Bytes

To be embedded in each web component custom element, the individual pieces must be small. Thus imm-dom is designed to include only the parts actually used when paired with a tree-shaking tool like rollup.

One component might only use imm_set() from imm_dom_core.js for ~ 1350 bytes minified; ~ 700 brotli.

An web component may take advantage of ImmElem from imm_elem.js for ~ 2700 bytes minified; ~ 1200 brotli.

A heavy rendering component may take advantage of ImmRAF from imm_elem_raf.js for ~ 3200 bytes minified; ~ 1500 brotli.

The entire library is ~ 9500 bytes minified; ~ 4000 brotli -- perfect for bundling a larger web component library and sharing structure.

| module | brotli | minified | source | |:-----------------|---------:|---------:|---------:| | index | 3910 B | 9462 B | 21672 B | | imm_dom | 697 B | 1344 B | 3562 B | | imm_elem | 1203 B | 2684 B | 7317 B | | imm_tmpl | 951 B | 1918 B | 5623 B |

See auto-generated compressed size report.

License

BSD 2-clause