r/javascript • • Oct 22 '19

Dead-Simple JavaScript Components w/o the overhead

https://medium.com/@patrickwees/flexible-javascript-components-w-o-the-overhead-b0c5c0dcb42e?source=friends_link&sk=99c4370a3ae8aa2c7f990401185240a3
1 Upvotes

22 comments sorted by

View all comments

16

u/braindeadTank Oct 22 '19
  1. Your "lib" vomits a string into innerHTML and then

  2. forces you to do everything else by hand, except

  3. "managaging containers" - which honestly seems random and useless

  4. it's a 100 lines of code lib that have a dependence on 80kb jQuery here goes your "no overhead"

  5. the dependency on jQuery is not listed in any way

  6. not only that, you assume that $ is jQuery, you didn't even bother to write jQuery in your code, which means it will sometimes randomly break

Thanks, I hate it.

7

u/meisteronimo Oct 22 '19

Thanks, I hate it.

wtf dude. If you'd recommend to maybe try dom queryselector instead of jquery than just fucking say so.

3

u/braindeadTank Oct 23 '19

Actually using jQuery is the least of the problems here, I wouldn't complain about component lib that had a dependency on jQuery if the lib was actually decent and the dependency was at least listed and used properly (though I would suggest to ditch it or make it optional).

Now, I wouldn't be so direct if the OP posted this as attempt to grow, or experiment, or something. But when they actually write an entire article for a lib, encouraging the reader to use it, I feel like I have every right to be clear about how bad I actually think it is.

1

u/Kiwi_Taster Oct 23 '19

The lib was an experiment to see how easy it is to write stateful, reusable components with vanilla js. The lib just provides helper functions that you can then use in any design pattern, although I think it helps to encourage encapsulation. Most of the 'component functions' in the examples are plain js, that just use one patchScript call to render. I wrote the article in an attempt to get feedback (which worked!). I know this is useful for myself at the very least. :)

6

u/Kiwi_Taster Oct 22 '19 edited Oct 22 '19

The dependency on jQuery was just for my prototyping phase. It can be very easily removed and was the plan, hence why I didn't mention it here.

The "forces you to do everything else by hand" aspect was kind of the whole point. I just wanted a function to return a component which I could manage myself. With nothing else included.

Thank you for the feedback :)

UPDATE: jQuery has been removed as a dependency.

1

u/suarkb Oct 22 '19

I love this

1

u/kap89 Oct 22 '19

Add a very low quality of the code and no tests whatsoever to the list.