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

hotjs

v1.0.9

Published

Peacefully simple view layer. Because React is still too complicated.

Downloads

3

Readme

Tweet

What is Hut?

Hut stands for HTML (and CSS) Under TypeScript. It's is an ultra-ergonomic HTML element construction library. Call functions. Get HTMLElement objects with event bindings and CSS styling attached. That's it.

It turns out, this is all you need to create very complex UIs. You don't need React, Vue, Angular, or any of the others. These things are complicated UI sub-systems that run around behind the scenes and do a bunch of weird magic for you in order to keep your view in sync with your data. You have to do things their way, otherwise, the magic won't work.

But by making controllers that are just plain TypeScript classes, and using the DOM itself as the backing store for view state, you can drop out the complexities associated with model/view synchronization. The view, the controller, and even (to some degree) the model become one and the same. Some devs will shudder at this. But by organizing your code like this, you can end up with a code base that is vastly less complex, easier to debug, and exhibits less surprising behavior.

Unfortunately, it's very hard to illustrate the benefit with silly 5-line code-golf style examples. The real test is how easy it is to iterate and debug a 50K LoC app with hundreds of components. As someone who has now built a few complex apps with Hut, there's now zero chance of me using React to build an app from scratch.

Why Use Hut?

  • No bloat. The whole library is only 2.3KB.
  • No props / state / special controllers that need to be inherited.
  • No weird or unpredictable framework "magic".
  • No performance overhead.
  • No virtual DOM.
  • No JSX.
  • No SASS / LESS / PostCSS. Write your CSS in TypeScript, and get all the benefits of styling becoming just another part of the code.
  • No learning curve. (There's a mindset shift. But if you know HTML, CSS, and JavaScript, you'll be able to get the hang of it within a few minutes.)

Also:

  • Hut is being used in production (to build the Direct app).
  • Many years in the making. Has passed through many different design variations.
  • Works with ES modules, no modules (script include), or CommonJS
  • Works in Node.js / Deno for server-side HTML generation

Why Not Use Hut?

  • React / Vue have stronger ecosystems. But for a battle-tested 2.3KB library that's not doing very much, how important really is an ecosystem?
  • No mobile-native UI (React Native) equivalent. If someone wants to make a Hut backend for NativeScript, send me a Tweet.

Installation

<script src="https://cdn.jsdelivr.net/npm/[email protected]/hut.min.js"></script>

Or

npm install hut-lib --save

Getting Started

An Example Controller

class MyController
{
	readonly head;
	
	constructor()
	{
		this.head = hot.div(
			{
				width: "100px",
				height: "100px",
				backgroundColor: "red",
			},
			hot.button(
				hot.text("Click me"),
				hot.on("click", () => this.handleClick())
			)
		);
	}
	
	private handleClick()
	{
		alert("Clicked!");
	}
}

// Somewhere in your initialization code:
document.body.append(new MyController().head);