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

uhtml

v4.5.11

Published

A micro HTML/SVG render

Downloads

11,201

Readme

µhtml

Downloads build status Coverage Status CSP strict

snow flake

Social Media Photo by Andrii Ganzevych on Unsplash

uhtml (micro µ html) is one of the smallest, fastest, memory consumption friendly, yet zero-tools based, library to safely help creating or manipulating DOM content.

📣 uhtml v4 is out

Documentation

Release Notes


Exports

  • uhtml as default { Hole, render, html, svg, attr } with smart auto-keyed nodes - read keyed or not ? paragraph to know more
  • uhtml/keyed with extras { Hole, render, html, svg, htmlFor, svgFor, attr }, providing keyed utilities - read keyed or not ? paragraph to know more
  • uhtml/node with same default exports but it's for one-off nodes creation only so that no cache or updates are available and it's just an easy way to hook uhtml into your existing project for DOM creation (not manipulation!)
  • uhtml/init which returns a document => uhtml/keyed utility that can be bootstrapped with uhtml/dom, LinkeDOM, JSDOM for either SSR or Workers support
  • uhtml/ssr which exports an utility that both SSR or Workers can use to parse and serve documents. This export provides same keyed utilities except the keyed feature is implicitly disabled as that's usually not desirable at all for SSR or rendering use cases, actually just an overhead. This might change in the future but for now I want to benchmark and see how competitive is uhtml/ssr out there. The uhtml/dom is also embedded in this export because the Comment class needs an override to produce a super clean output (at least until hydro story is up and running).
  • uhtml/dom which returns a specialized uhtml compliant DOM environment that can be passed to the uhtml/init export to have 100% same-thing running on both client or Web Worker / Server. This entry exports { Document, DOMParser } where the former can be used to create a new document while the latter one can parse well formed HTML or SVG content and return the document out of the box.
  • uhtml/reactive which allows usage of symbols within the optionally keyed render function. The only difference with other exports, beside exporting a reactive field instead of render, so that const render = reactive(effect) creates a reactive render per each library, is that the render(where, () => what), with a function as second argument is mandatory when the rendered stuff has signals in it, otherwise these can't side-effect properly.
    • uhtml/signal is an already bundled uhtml/reactive with @webreflection/signal in it, so that its render exported function is already reactive. This is the smallest possible bundle as it's ~3.3Kb but it's not nearly as complete, in terms of features, as preact signals are.
    • uhtml/preactive is an already bundled uhtml/reactive with @preact/signals-core in it, so that its render exported function, among all other preact related exports, is already working. This is a drop-in replacement with extra Preact signals goodness in it so you can start small with uhtml/signal and switch any time to this more popular solution.

uhtml/init example

import init from 'uhtml/init';
import { Document } from 'uhtml/dom';

const document = new Document;

const {
  Hole,
  render,
  html, svg,
  htmlFor, svgFor,
  attr
} = init(document);

uhtml/preactive example

import { render, html, signal, detach } from 'uhtml/preactive';

const count = signal(0);

render(document.body, () => html`
  <button onclick=${() => { count.value++ }}>
    Clicks: ${count.value}
  </button>
`);

// stop reacting to signals in the future
setTimeout(() => {
  detach(document.body);
}, 10000);