Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Tiny JS – A Tiny JavaScript Library for Easy DOM Creation (github.com/victorqribeiro)
7 points by atum47 27 days ago | hide | past | favorite | 4 comments
Hi everyone, the other day I was here cause I thought I came up with a neat way of creating HTML via JavaScript [1] - After some iterations, I'm quite content with the code I wrote. Since I intend to use this in my personal projects, I thought others might as well.

1 - https://news.ycombinator.com/item?id=41451559




I've recorded a short video showing a little bit of TinyJS if you're interested - https://www.youtube.com/watch?v=otz7sv_wpFA


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


Ok, now that I've looked at both sources, I asked ChatGPT to drawn a comparison between the projects.

https://chatgpt.com/share/d38144b6-d088-4887-a2d2-50b931c6af...

One thing it got wrong is that TinyJS can handle events, you can just pass a onclick property via props and it will work `div({onclick: () => alert(1)}, 'click me')`


I haven't. I tried googling Hyperscript and other stuff came up. Seeing it now I'm glad I end up having the ideia of registering each tag as a function, I think it reads better. (Editing) I'm now seeing your second link, it is quite similar to what I've created. Haven't looked at the source code yet.

> I think it's fair to prefer Hyperscript

It is.


[deleted]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: