| ▲ | blakewatson 7 hours ago |
| Related: This is a nice write-up of how to write reactive jQuery. It's presented as an alternative to jQuery spaghetti code, in the context of being in a legacy codebase where you might not have access to newer frameworks. https://css-tricks.com/reactive-jquery-for-spaghetti-fied-le... |
|
| ▲ | lioeters 3 hours ago | parent | next [-] |
| This brought me flashbacks of jQuery spaghetti monsters from years ago, some were Backbone related. In retrospect, over-engineered React code can be worse than decently organized jQuery code, but some jQuery mess was worse than any React code. So I guess I'm saying, React did raise the bar and standard of quality - but it can get to be too much, sometimes a judicious use of old familiar tool gets the job done. |
| |
|
| ▲ | Klaster_1 7 hours ago | parent | prev [-] |
| I used this approach before and it indeed works better than the 2010-style jQuery mess. A good fit for userscripts too, where the problem you attempt to solve is fairly limited and having dependencies, especially with a build steps, is a pain. Note that you don't need jQuery for this at all, unless you are somehow stuck with ancient browser support as a requirement - querySelector, addEventListener, innerHtml - the basic building blocks of the approach - have been available and stable for a long time. |
| |
| ▲ | doix 7 hours ago | parent [-] | | Unfortunately, nowadays writing userscripts is much harder than it used to be. Most websites are using some sort of reactive FE framework so you need to make extensive use of mutationObservers (or whatever the equivalent is in jQuery I guess). | | |
| ▲ | hebelehubele 2 hours ago | parent | next [-] | | I often go for `setInterval` over `MutationObserver` because it works and I don't need instant reactivity and I don't have to think too much about it. | |
| ▲ | egeozcan 2 hours ago | parent | prev | next [-] | | It's easier to write with LLMs. One-off projects (the way I treat userscripts) is where they really shine. Oh the horrible things I do with Instagram... | |
| ▲ | Klaster_1 4 hours ago | parent | prev [-] | | Very true. I guess that depends on what websites you find issues with? I just checked mine and all of those are quality of life improvements for fully server rendered sites like HN or phpBB forums. | | |
| ▲ | doix 4 hours ago | parent [-] | | Yeah, I mostly use it for QoL improvements but for work related things. So Jira, Bitbucket, GitHub, Linear etc. basically whatever my employer uses. Back in the early 2010s most of that software was fully server rendered. Nowadays it's pretty rare for that to be the case. I just try and get LLMs to do it for me because I'm lazy, and they like to use setInterval instead of mutationObservers and if it works, I just live with the inefficiency. | | |
| ▲ | mschuster91 2 hours ago | parent [-] | | The Atlassian stack is particularly bad to extend IMHO given that there are sooooo many API endpoints that their UI calls and most of them are dog slow. |
|
|
|
|