Show HN: Auto-generate vanilla JavaScript alternatives for jQuery methods

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • cash

    An absurdly small jQuery alternative for modern browsers. (by fabiospampinato)

  • I'm not sure I buy this argument, one can't just say that ~30kb isn't a lot because 30 is a number perceived as low, would 30kb be justified for a library that allows you to toggle a class on a node? Of course it wouldn't, you need to measure what you are getting for 30kb.

    I don't buy the second part of the argument either, you can load a 1000kb image on a blog post and that won't have nearly the same effect as loading 1000kb of JS. The JS needs to be parsed and executed and maybe the site doesn't even work without it, the image can probably be rendered progressively, can be decoded in another thread, nothing is really waiting on it to load, and if it doesn't load at all it's not the end of the world anyway.

    With ~4kb you can have Preact, is jQuery Slim (~26kb) giving you ~6.5x times as much value as Preact really? Maybe it is, probably not.

    For some context I maintain a ~6kb rewrite of a subset of jQuery (https://github.com/fabiospampinato/cash), which IMO is much better value proposition for many use cases.

  • replace-jquery

    Automatically finds jQuery methods from existing projects and generates vanilla js alternatives.

  • - It seems to have subtle bugs, like the way the events string is split makes so that double consecutive spaces in it (which can happen as a result of a typo) will result in listening to the empty string event. Basically: 'foo bar'.split ( ' ' ) => ['foo', '', 'bar'].

    The `on` method we are using in Cash [1] is a lot more convoluted than that. On one hand it requires more bytes, but on the other the chances of it behaving exactly like jQuery's are much higher. In fact we can also run jQuery's test suite with Cash to spot issues.

    Feel free to ping me if you are interested in joining forces.

    [0]: https://github.com/fabiospampinato/cash

    [1]: https://github.com/sachinchoolur/replace-jquery#on

    [2]: https://github.com/fabiospampinato/cash/blob/master/src/even...

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • zepto

    Zepto.js is a minimalist JavaScript library for modern browsers, with a jQuery-compatible API

  • Vanilla JS refers to Javascript that uses native browser methods instead of relying on a library. This is just replacing jQuery with another library constructed on the fly.

    I don't see the point and there are already minimal and modern alternatives with the jQuery API like zepto and cash.

    1) https://github.com/fabiospampinato/cash 2) https://github.com/madrobby/zepto

  • tiny-events.js

    TinyEvents is a tiny event utility library for modern browsers(IE 11+). Supports jQuery-like syntax. Just 1 kb gzipped.

  • Yes, I agree with you the events part needs to be improved and well documented. (It actually supports namespacing.) I fixed most of the things in https://github.com/sachinchoolur/tiny-events.js and need to make the changes here as well.

    My intention was not to build another JavaScript utility library. I just wanted to make my JavaScript libraries jQuery independent.

  • jQuery

    jQuery JavaScript Library

  • And I will spare you all jQuery's implementation, which is huge, but it can be seen here:

    https://github.com/jquery/jquery/blob/main/src/attributes/cl...

  • closure-compiler

    A JavaScript checker and optimizer.

  • > but I went so far as comparing the GZIP output of calling `for ()` vs `forEach`, etc

    AFAIK Google Closure Compiler [1] does similar things automagically.

    [1] https://github.com/google/closure-compiler

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts