qpixel icon indicating copy to clipboard operation
qpixel copied to clipboard

Code style: discuss removing dependency on jQuery

Open trichoplax opened this issue 1 year ago • 4 comments

If there is consensus among the team, I'd like to see jQuery removed from the codebase. I'm raising this issue so people can discuss and add reasons for or against.

trichoplax avatar Oct 11 '24 04:10 trichoplax

My reasons for preferring native JS over jQuery:

  • Nowadays jQuery isn't much shorter than native JS, and browser compatibility is no longer a problem (any counterexamples that still apply?)
  • jQuery is less readable (subjective but I prefer spelt out names, particularly now that $ is used for JS template literals)
  • jQuery is slower
  • jQuery is potentially less secure
  • New contributors may have experience with JavaScript but not jQuery

trichoplax avatar Oct 11 '24 04:10 trichoplax

Seconding the motion. There are also reliability concerns as we have to wait until (and if it is available at all in the first place) it's available before we are able to make any JS-based actions. In addition, we have to ensure that it is loaded on each and every page. Moreover, strictly typing our JS assets (not necessarily via TypeScript - we already have a lot typed with JSDoc), which would've prevented at least several production-facing bugs already, requires making the developer environment aware of jQ, which is is not as straightforward with our codebase.

Oaphi avatar Oct 11 '24 04:10 Oaphi

I think I agree in principle. A lot has moved on from a few years ago when we last had this discussion and I was on the fence.

My main remaining concern would be browser compatibility; jQ provides us guaranteed compatibility based on the version we use; browser API support can vary and there may well be places we need to add fallback logic, which I dislike. Is that worth removing the dependency? On balance, probably.

I'll start a branch/PR to remove jQuery. Contributions welcome.

ArtOfCode- avatar Oct 12 '24 11:10 ArtOfCode-

I'll leave setting priority to @ArtOfCode- .

cellio avatar Oct 15 '24 17:10 cellio