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

not-react-dom

v1.0.0

Published

A minimal implementation of a React-like library

Downloads

7

Readme

Exploring notReact

This is an exploratory work to determine how a minimal reimplementation of React, called notReact, can succeed in replicating the basic behavior of React. It is so minimal that only accepts pure functional "not-react" components.

The (revised) minimal notReact implementation is in src/not-react.js. It only has 140 bytes long! And could even be reduced to 44 bytes if willing to go all the way down :D

var notReactDOM={render(h,e){e.innerHTML=h}}

Usage

Check out the examples folder. The examples follow the Quick Start guide of React.

Install

If you ever dare using this library for anything, you can npm install not-react-dom or just copy the file. That's it!

The library is conveniently wrapped in an UMD loader so it can be safely loaded using RequireJS, Node.js' require() or just an <script> tag that will expose the global notReactDOM object.

Conclusions

The most relevant finding of this exercise is that the lib's code needed to implement the "hello world" example did not need a single change to later implement all the other examples, no matter how complex the example was. This is a clear difference with any other framework or library, that needs more and more code to support additional use cases.

Perhaps that characteristic is good enough to forgive some negative aspects found along the way:

  • Mapping a list of components into HTML needs .join('') at the end to avoid JavaScript to join the array of strings with commas. Not bad considering the final size of the library.

  • Event handling is not "elegant" as handler calls are plain text and handlers need to be global. Fixing that would have required tons of additional logic!

  • State? Global state!? Well... if there only are functional components, the state has to be somewhere. And that "somewhere" has to be accessible by the global event handlers.

  • Rendering large pages would be really slow as the whole DOM tree is rewritten on each state change. For small pages or document trees it would work pretty well anyway.

  • And, no, no fancy stuff. No error checking, sanitization, security, nothing. Only suitable for Perfect Programmers (TM) and Lovely Users (TM).

License

Unlicense