Live data from Hacker News

TinyJS – Shorten JavaScript QuerySelect with $ and $$

github.com

11–20 of 94 posts

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#11

jQuery II: The Quickening! I recently built a toy Golang SSR project using Zepto, a jQuery-like library, and felt like I was 17 again (**EDIT: it's unmaintained - don't use it). Also of note is that "Highlander II" takes place in the year 2024 [1]. It's a sign! Everything old is new again! `$` is immortal! [1] https://en.wikipedia.org/wiki/Highlander_II:_The_Quickening

[deleted]

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#12
Calling those $ and $$ selector helper functions new is a bit disingenuous. They’ve been present as Chrome dev tools shortcuts for years. Let alone JQuery, I’ve also spent years seeing little articles about this neat trick on everything from medium to dev.to.

I recommend the author remove that or note inspiration from the README to avoid detracting from the rest of the work. I realize there’s more here than the traditional document.querySelector.bind(document) assignment.

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#13

> This README was generated by ChatGPT Damn good README. Also, good library.

Too wordy yet doesn’t even explain the tag part of the API. It just shows up in an example.

A readme should be more reference / show and less drivel.

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#14
post #5

I do believe I've seen something like this under another name. Using "$" to shorten JavaScript? That seems a lot like jQuery. > This README was generated by ChatGPT You don't need AI to explain this one.

That explains the pompous introductory tone. Ugh.

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#15

This is the whole code: (() => { const assignDeep = (elm, props) => Object.entries(props).forEach(([key, value]) => typeof value === 'object' ? assignDeep(elm[key], value) : Object.assign(elm, {[key]: value})) const tagNames = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'd…

    window['$'] = selector => document.querySelector(selector)
    window['$$'] = selector => Array.from(document.querySelectorAll(selector))
is really what I want to have

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#18

may I ask what's the point of `const tagNames =`? removing it would make no difference, as far as I can tell - just make sure the previous line ends with a semicolon (or add it at the same line as the opening square bracket)

Well, it's polluting the global window scope with all those helpers.

That's a reason to never use this imo.

There are plenty of other jquery-lite helper libraries out there. 95 percent the utility with hardly any cost in terms of script size.

Converting querySelectorAll to an array is honestly most of the benefit of these libraries.

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#19

jQuery II: The Quickening! I recently built a toy Golang SSR project using Zepto, a jQuery-like library, and felt like I was 17 again (**EDIT: it's unmaintained - don't use it). Also of note is that "Highlander II" takes place in the year 2024 [1]. It's a sign! Everything old is new again! `$` is immortal! [1] https://en.wikipedia.org/wiki/Highlander_II:_The_Quickening

Zepto is unmaintained, which isn’t good for security issues or bugs, unfortunately.

jQuery proper is both maintained and has actively been working on a 4.0 release and still gets security and bug fixes

Re: TinyJS – Shorten JavaScript QuerySelect with $ and $$

#20

jQuery II: The Quickening! I recently built a toy Golang SSR project using Zepto, a jQuery-like library, and felt like I was 17 again (**EDIT: it's unmaintained - don't use it). Also of note is that "Highlander II" takes place in the year 2024 [1]. It's a sign! Everything old is new again! `$` is immortal! [1] https://en.wikipedia.org/wiki/Highlander_II:_The_Quickening

I also created almost 10 years ago Umbrella JS, which is a tiny jQuery replacement but with more array-like arguments in the functions:

https://umbrellajs.com/

https://www.bennadel.com/blog/4184-replacing-jquery-110kb-wi...

Post reply on HN