September 6th, 2024

Show HN: Tiny JS – A Tiny JavaScript Library for Easy DOM Creation

Tiny JS is a lightweight JavaScript library that simplifies DOM manipulation, allowing dynamic HTML creation, deep property assignment, easy content appending, and straightforward installation, while encouraging community contributions.

Read original articleLink Icon
Show HN: Tiny JS – A Tiny JavaScript Library for Easy DOM Creation

Tiny JS is a lightweight JavaScript library designed to simplify DOM manipulation. It allows developers to dynamically create HTML elements, supports deep property assignment for complex structures, and simplifies content appending by accepting both strings and elements. The library provides a convenient way to select DOM elements using `$` for single selections and `$all()` for multiple selections. Tiny JS attaches functions for each HTML tag to the global window object, enabling element creation by calling the tag name as a function with optional properties and child elements. Installation is straightforward by including the tiny.js script in a project. The library supports a variety of HTML tags, including text, interactive, media, and container elements. Contributions to the library are encouraged through issues and pull requests, making it a collaborative tool for developers aiming to enhance their DOM manipulation capabilities in JavaScript.

- Tiny JS simplifies DOM manipulation with dynamic HTML element creation.

- It supports deep property assignment for complex nested structures.

- The library allows easy content appending and element selection.

- Installation is simple by including the tiny.js script in projects.

- Contributions to the library are welcomed from the developer community.

Link Icon 3 comments
By @atum47 - 7 months
I've recorded a short video showing a little bit of TinyJS if you're interested - https://www.youtube.com/watch?v=otz7sv_wpFA
By @genezeta - 7 months
One of the comments the other day was "You have reinvented Hyperscript".

In case you didn't see it, they meant this [0] and also this [1].

I don't mean this as a critique or dismissal of your idea, but I think it's fair to prefer Hyperscript since it's well tested code and has a couple of additional features (like event handler support) without being much larger than your own code. Also, I think Hyperscript is more correct in the way they build the elements.

[0] https://github.com/hyperhype/hyperscript

[1] https://github.com/ohanhi/hyperscript-helpers