DEV Community

Cover image for 1KB Frontend Library

1KB Frontend Library

Fedor on February 08, 2025

Today’s Challenge: Build a 1KB Frontend Library Let’s tackle an exciting challenge today: creating a frontend library that’s just 1 kilo...
Collapse
 
benny00100 profile image
Benny Schuetz • Edited

Awesome project, especially because I think todays frameworks are way too bloated.

Btw. I also created a small anti-framework called InfrontJS.

I am really interested what you are coming up with. Maybe I can pick up some ideas for my framework if you dont mind ;-)

Collapse
 
fedia profile image
Fedor

Oh, so these things are called anti-frameworks - good to know! Awesome site, and it's great to see your framework evolving! I still can’t manage to work on pet-projects with that level of discipline.

Collapse
 
dariomannu profile image
Dario Mannu

haha, I started the same way, 100LoC, template literals+observables (👎👎👎 signals lol), used to call it the "No Framework"... then it evolved into a UI library, slowly growing into a full, modular framework (going to happen to all of you, guys, it's a law of nature)...

Nice work, guys, both!

Thread Thread
 
benny00100 profile image
Benny Schuetz

Good to meet some "same-minded" people here 👍

Collapse
 
benny00100 profile image
Benny Schuetz

Thanks for your head-ups. Yeah, I came across the term "anti-framework" on a blogpost somewhere and somehow liked it ;-)

Collapse
 
marceloxp profile image
Marcelo de Souza Lima

Create a comparative table with react-based "black spells". Your framework can win by simplicity. 😁

Collapse
 
daniel15 profile image
Daniel Lo Nigro

Very nice post! Thanks for writing it.

I used to do something like this, but I've moved back towards server-side rendering and inserting chunks of HTML on to the page, similar to how htmx does it. Works well in a surprisingly large number of cases, especially in cases where you'd have to persist the data server-side anyways. One of the things I miss with an approach like that is optimistic updates on the client side, which your library would handle well (render with the new data, then on error revert the data back to the old data).

Collapse
 
thescottyjam profile image
theScottyJam

I love the idea of copy-paste tools, for when you're working on a smaller project and don't really need all the weight of a full-fledged framework. I also love how small you were able to get this.

I had attempted to make a copy-paste framework once upon a time. It ended up being 1.5 kb gzipped. You got me beat :). But it looks like fundamentally, we took a similar approach, namely building everything on top of signals and an html template tag.

I hope one day in the future these sorts of things can just be in native JavaScript.

Collapse
 
fedia profile image
Fedor

Thanks! Really cool to see similar projects from like-minded devs! snap.js has way more features - no wonder the size is a bit bigger.

Collapse
 
artydev profile image
artydev

Great. I am militant of minimalisme🙂

Collapse
 
intermundos profile image
intermundos

Great attempt.
Wondering if that would work in complex applications…?

Collapse
 
fedia profile image
Fedor

This implementation of signals definitely has its limitations. They're described in the article I linked to. Other than that, it's pretty standard and basic DOM manipulation. I'll write a separate article about optimizing list rendering.

Collapse
 
dariomannu profile image
Dario Mannu

now I wonder why so many people (incl. myself) keep re-inventing the same no-framework/anti-framework (ok, that's easy, that's the React/Angular Fatigue, right?), instead of teaming up and building something big together (ego, perhaps? Everybody wanting to become "the man" who changed the world and get 100% of the credit? Other realistic explanations? I did it because I needed a framework and was in total disagreement with the approach taken by most existing ones. How about you guys?)...
So in the end there are dozens of talented creators around who built 100% of something nobody uses and knows about, even if it's a brilliant product that would deserve taking over the market...

Collapse
 
fedia profile image
Fedor

To dominate the market, you need marketing. So, in my opinion, it’s not about ego or chasing GitHub stars. It’s more about sharing what you’ve built because you genuinely enjoy it and find it interesting.

Collapse
 
joo_pedroviana_14549d71 profile image
João Pedro Viana

useless

Collapse
 
plleonart profile image
Pascal Lleonart

why are you using a WeakSet for disposed?

Collapse
 
fedia profile image
Fedor

WeakSet allows garbage collection of disposed effects, so it should be more memory efficient.

Collapse
 
kien5436 profile image
Phạm Trung Kiên

after every framework, I see react still right from the beginning