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

preact-htm-signals-standalone

v0.0.16

Published

A single, standalone version of Preact, HTM and Preact Signals. No external dependencies, just one single file.

Downloads

19

Readme

Preact + HTM + Preact Signals standalone

A single, standalone version of Preact, HTM and Preact Signals. No external dependencies, just one single file.

One single file that you can use via CDN or download locally for offline use.

Usage

Direct CDN import in HTML

<div id="app"></div>
<script type="module">
  import {
    html,
    render,
    signal,
  } from "https://cdn.jsdelivr.net/npm/preact-htm-signals-standalone/dist/standalone.js";

  const count = signal(0);

  function App() {
    return html`
      <div>
        <h1 class>Hello World!</h1>
        <button onClick=${() => (count.value += 1)}>
          Increment with signal
        </button>
        <p>Counter: ${count}</p>
      </div>
    `;
  }

  render(html`<${App} />`, document.getElementById("app"));
</script>

Via npm (not recommended)

I don't recommend installing this package via NPM. It's best to install Preact, HTM and Preact Signals separately:

npm install preact htm @preact/signals
# or yarn
yarn add preact htm @preact/signals
# or pnpm
pnpm install preact htm @preact/signals

Motivation and goals

My main motivation is to be able to download the entirety of Preact + HTM + Preact Signals offline in a single file.

You can absolutely do the following (and it works fine):

<script type="module">
  import { h, render } from "https://cdn.skypack.dev/preact";
  import htm from "https://cdn.skypack.dev/htm";
  import { signal } from "https://cdn.skypack.dev/@preact/signals";
  const html = htm.bind(h);
</script>

or go shorter and do this:

<script type="module">
  import { html, render } from "https://esm.sh/htm/preact";
  import { signal } from "https://esm.sh/@preact/signals";
</script>

or even shorter (via npm.reversehttp.com, thanks Jason Miller for the tool!):

<script type="module">
  import {
    html,
    render,
    signal,
  } from "https://npm.reversehttp.com/preact,htm/preact,@preact/signals";
</script>

However, due to my work limitations (i.e. my internal Preact apps run on restricted corp intranet), having a downloadable, offline version is required, hence the need for a prebundled, no-dependency, single script that I can easily download and use offline.

Simply put, my ideal situation looks like this (made possible by this project):

<script type="module">
  // Download the prebundled scripts locally for offline use
  import { html, render, signal } from "./preact-htm-signals-standalone.js";
</script>

Inspired by the standalone version of Preact + HTM.

All rights belong to Preact, HTM and Preact Signals owners/maintainers.

Building from source

Install and bundle them (via Microbundle):

git clone https://github.com/mujahidfa/preact-htm-signals-standalone.git
cd preact-htm-signals-standalone
pnpm i
pnpm bundle
npm publish --dry-run # to test out publishing to npm
npm publish