4 ms·
I’d suggest not naming the your main interface of your library “$”, for various obvious reasons.
by garrettjoecox 3y ago
I’d suggest not naming the your main interface of your library “$”, for various obvious reasons.
- regularfry 3y agoObvious if you've been around long enough. I wouldn't be surprised if the majority of people reading this have never actually worked with jquery, only heard the bedtime horror stories. (I mean, leaving aside the fact that it's utterly nondescriptive...)
- andybak 3y agoI still rather miss it. Sniff...
- dr_kiszonka 3y agoI used jQuery in a few personal projects and it was very useful. It was 10 - 15 years ago, so I am sure there are better tools now, but for a hobbyist it was great.
- andybak 3y agoThe syntax still seems much more pleasant for DOM manipulation than vanillaJS. It had a nice pseudo-functional interface and a ton of elegant helpers. Whenever I do DOM manipulation in vanilla I wonder to myself if the API couldn't be a bit more user-friendly and readable.
- eternityforest 3y agoI think I'd definitely use some kind of library if I still had to touch the DOM heavily. I liked JQuery, but I like reactive frameworks a lot more.
- troupo 3y agoFor low-level-ish work (like DOM manipulation) there are still no better tools than jQuery
- explaininjs 3y agoAlso browser dev tools still implement $ as a document.querySelector sort of alias.
- keepamovin 3y agoThanks for your concern around possible naming conflicts! Actually the name is deliberate. A homage to jquery, at first I even considered calling this library JCustom. I think the logic is cool, as Hyphen aspires to be a kind of layer atop custom elements, as JQuery was a layer atop the DOM (and MUCH more!). Yet, the age of JQuery has passed. It's light has gone out of the world, and John Resig has retreated to the West with the Elves. I don't think it's really an issue. Also, it's time to consider that passing the torch of '$' is ok. Moreover, perhaps it was never not ok. As in, the existence of a library that binds to a tiny symbol should not restrict others from using the same symbol. Otherwise it would be kind of like 'variable name squatting'--not good! Dollars for all, I say! Who's with me??? So while I get your concern about conflicts there's always been ways to avoid namespace conflicts, such that these avoidance functions have been built into the libraries themselves, in the form of: noConflict(). I think that's sufficient. And, not that it's the best guide of best practice, but for a long time Chrome, Safar and Firefox have included $, $$ and so on functions in their consoles, as part of the Web Console API. I get you might be concerned about this, so you can easily modify this tiny base class of Hyphen to call the base whatever you like. Reasonably, there's plenty of names that could be good for a base class, given whatever it is that you might want! :) For me, tho, I think $ is a beautiful symbol to name it after so I'm sticking with that. JQuery can bind to other symbols, but it's also not as common these days. I'm not worried about it. Do you think I should be worried about this? If so why?