News for hackers. Stuff that matters.
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by franciscop on Sunday August 19, 2018 @05:01AM (#17793376)
I submitted this 3 years back [1] when I was starting. But now I think it's finished and well polished, so I am resubmitting it. I am happy to say that I don't normally find bugs anymore and the bug reports have slowed down while adoption has skyrocketed [2] [3]

It follows loosely a subset of jQuery methods, but it adds some others where relevant for common JS patterns (.handle() == .on() + e.preventDefault()) and the existing ones are generally more flexible.

[1] https://news.ycombinator.com/item?id=10954191

[2] https://npm-stat.com/charts.html?package=umbrellajs&from=201...

[3] https://www.jsdelivr.com/package/npm/umbrellajs

Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by brennebeck on Sunday August 19, 2018 @09:35AM (#17794246)
Looks interesting. How compatible with jquery is it? You say a subset, but is that an exact subset that would pass tests for those methods? Either way, well done!
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by franciscop on Sunday August 19, 2018 @11:34AM (#17794658)
No, no method would pass all of the tests for said method in jQuery. I believe a part of those tests in jQuery are retroactive to settle the behavior of very edge undocumented cases, which might be different in Umbrella.js.

I did in fact try to improve the size of jQuery, but the tests are too coupled to the internal behavior of the methods, even if undocumented and (potentially) unintended initially. So it was very difficult even to change the most basic things, let alone change the internal structure of the whole method.

With Umbrella JS I'm trying to get to somewhere closer to native Javascript than jQuery. See for instance the arguments of any looping function (follows similar to the native arrays), or how things like .addClass(name) [1] are thin wrappers around .classList.add(name) (but quite more permissive/flexible). So it will follow closer to classList behavior than to whatever is defined in jQuery's tests, which is a win-win IMHO (since it also makes for a much smaller size, compare to jQuery's .addClass(name) [2]).

[1] https://github.com/franciscop/umbrella/blob/master/src/plugi...

[2] https://github.com/jquery/jquery/blob/master/src/attributes/...

Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by sonofblah on Sunday August 19, 2018 @10:41AM (#17794478)
Is this criterion keeping you from using the framework right now?
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by pvorb on Sunday August 19, 2018 @04:40PM (#17796065)
Nice that you're using npm-stat.com for checking adoption. I should use your library on the site.
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by franciscop on Sunday August 19, 2018 @05:06PM (#17796175)
Thank for npm-stat! I use it a lot and love it, see my other repos from my website (in my profile).

Not sure how much sense it makes for Umbrella JS though, since traditionally it'd be used under a CDN but now with webpack it's treated as another dependency. Indeed, the CDN has remain constant-ish but the npm one has grown quite a bit in the last year.

Feel free to use Umbrella JS and ask me any question!

Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by pvorb on Sunday August 19, 2018 @05:17PM (#17796221)
Yeah, right. I thought I still had jQuery in there and thought about replacing it. But now as I looked at the code I realized that it's already mostly using Vanilla JS.
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by franciscop on Sunday August 19, 2018 @05:23PM (#17796256)
Oh really? I was surprised that there was even jQuery, and after checking it does seem there's a bit of jQuery there. "$" matches 53 times here: https://github.com/pvorb/npm-stat.com/blob/develop/src/main/...
Re:Show HN: Umbrella JS, a 2.5kb jQuery alternative by pvorb on Sunday August 19, 2018 @05:41PM (#17796329)
So I was wrong again. ;-) Just checked the package.json, but it's a static JS dependency that's not transpiled using Webpack.