this post was submitted on 15 Oct 2024
11 points (100.0% liked)

JavaScript

1972 readers
1 users here now

founded 1 year ago
MODERATORS
 

In PHP ecosystem there is a tool called Rector. It helps a lot in automated refactoring. It helps a lot in updating from a bad design pattern to another, update code to match a given framework updates, etc.

Maybe we could create a similar tool for client side Javascript to migrate away from jQuery to vanilla Javascript. Websites youmightnotneedjquery.com have a good collections of vanilla JS alternatives to jQuery.

While one could do it manually, on larger code bases, it is extremely tedious.

Maybe such tool exists and I am unaware of it?

At first, I thought about having such transformation as an optimization step in the bundler, but this is unnecessarily redundant and might cause a lot of troubles.

top 7 comments
sorted by: hot top controversial new old
[โ€“] lemmeBe@sh.itjust.works 4 points 3 weeks ago (2 children)

I'd give anything for such a tool years ago. Now - j what? ๐Ÿ˜„

[โ€“] bran_buckler@lemmy.world 2 points 3 weeks ago (2 children)

Iโ€™ve been out of the game for a few years. What do people use now instead with simple html sites?

[โ€“] lemmeBe@sh.itjust.works 7 points 3 weeks ago* (last edited 3 weeks ago)

HTML, CSS, Javascript. Works like a charm for simple sites, and it's very lightweight. Things've progressed a long way in these vanilla's. ๐Ÿ˜‰

[โ€“] Giloron@programming.dev 4 points 3 weeks ago

A lot of what jQuery provided is built in now. Selectors, AJAX, JSON conversion.

Version 4 is removing those redundant functions to streamline it to just the unique functionality.

[โ€“] dragnucs@lemmy.ml 0 points 3 weeks ago

Good for you. However many many people are still stuck with ugly ass slow poorly written jQuery code.

[โ€“] bjornsno@lemm.ee 2 points 3 weeks ago (1 children)

I believe https://github.com/facebook/jscodeshift is trying to be that tool for the typescript/js world. Doesn't have a mod for removing jquery but should be super doable.

[โ€“] dragnucs@lemmy.ml 1 points 3 weeks ago

This is awesome. Lookalike would enable code refactoring from jQuery to vanilla.

Thanks a lot!