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

keml

v3.1.0

Published

An HTMX alternative with a focus on performance, flexibility and, most of all, simplicity.

Downloads

685

Readme

What is KEML?

KEML is a lightweight flexible alternative to HTMX, built around the concept of actions.

The ideas that HTMX has recently made popular are, frankly, the best that the web community collectively has ever had.

However, like most great ideas, they are far more important than any actual specific implementation.

Despite offering a multitude of conveniences over HTMX and much greater flexibility, KEML still manages to be absolutely tiny in comparison.
KEML v3 is ~4.5k minified and not gzipped and HTMX v2 is ~49.2k minified and not gzipped (~11x smaller).

Motivation

Being small and fast and configuration/plugin free is not enough, when you are trying to compete with a well established and popular library.

So, why does KEML need to exist?

KEML was born out of the classic 1-to-1 problem of the traditional jQuery-esque web application, that the HTMX api does nothing to address.

Consider the following "idiomatic" HTMX code:

<button
  hx-post="/clicked"
  hx-trigger="click"
  hx-target="#result"
  hx-swap="innerHTML"
>
  Click Me!
</button>

<div id="result"></div>

Here the button element:

  1. can only react to exactly 1 event ("click")
  2. can only do 1 thing when that event happens (send a request to "/clicked")
  3. cannot delegate the request-sending to some other element/-s
  4. can only render the result into 1 (usually) target element
  5. has to know where that element is on the page, what its "id" and/or "class" attributes are
  6. has to decide for the target element the exact "hx-swap", of which there can only be 1

Out of these limitations arise:

  1. the need for a custom selector syntax built on top of the normal css-selector syntax
  2. the need for selectors in the first place, which you need to learn and understand to use the library effectively
  3. the implicit special handling of certain elements, like title and meta, present in the server response
  4. out of band swaps
  5. response selectors
  6. "hx-preserve"
  7. etc, etc, etc...

All which, are meant to solve real tangible application needs, but in the process of doing that over-complicate things that do not need to be complicated.

How is KEML different?

Consider the following KEML code, that works with the same backend:

<html>

<head>
  <title render="result"></title>
</head>

<body>
  <button
    on:click="handleClick doSomethingElse"
    on:dblclick="handleDoubleClick"
  >
    Click Me!
  </button>

  <button on:click="handleClick">Click Me, maybe?!</button>

  <input
    on="handleClick"
    post="/clicked"
    type="text"
    name="input1"
    result="result"
  >

  <input
    on="handleClick"
    put="/notification"
    type="text"
    name="input2"
  >

  <div
    render="result"
    position="replaceWith"
  ></div>

  <p
    render="result"
    position="append"
  ></p>
</body>

</html>
  1. both buttons initiate the same "handleClick" action on "click"
  2. the first button actually initiates two independent actions on "click", that could both do completely different things
  3. the first button also reacts to the double click event
  4. neither of the buttons needs to know how those actions are being handled, if at all
  5. the two text inputs both handle the "handleClick" action, but send completely different requests
  6. the first input gives the server response a render-able name "result"
  7. neither of the inputs knows anything about the rendering, whether or not anything is even going to be rendered at all, where and how
  8. the div, p and title elements render the same server response differently
  9. the div will be completely replaced with the response
  10. the p will append the response after its last child
  11. the title will replace all of its children with the response
  12. there is nothing special about the title element at all
  13. there's no need for ids, classes or selectors and the location of each element in the document is completely unimportant

None of the problems that HTMX tries to solve with the complications listed above even exist in this paradigm!

Is KEML feature-complete?

While nothing is ever truly complete, the current feature-set should be able to cover 99% of actually useful HTMX features.

I'm not going to claim that it is completely bug free and supports every browser under the sun, because it still has a long way to go until that becomes a reality.

Thus, all constructive feedback and criticism are very welcome!

If a feature of HTMX is missing, that means one of the following:

  • it is made unnecessary by a more flexible API
  • it is downright evil and/or going against the spirit of HATEOAS (e.g JSON endpoints, local templates and most forms of local state)
  • it wasn't implemented yet