4 ms·
why does the code use reactjs AND jquery ? https://github.com/debiki/talkyard/blob/master/package.json https://github.com/debiki/talkyard/blob/master/package.js
by sandGorgon 7y ago
why does the code use reactjs AND jquery ? https://github.com/debiki/talkyard/blob/master/package.json https://github.com/debiki/talkyard/blob/master/package.json
- alharith 7y agoWhat? Is this really controversial? Sometimes you need a UI library, sometimes you need really quick interactivity to toggle a menu. I use alpine.js on my marketing pages, and I use vue/svelte within sections of my app.
- dceddia 7y agoUsing them on separate pages is fine, but using React and jQuery on the same page is usually not a good idea since React needs to “own” its slice of the DOM and changing things in there with jQuery could cause weird bugs. But anyway, it’s impossible to tell from just the package.json file whether React and jQuery are being used on the same page, or just both used in different parts of the app.
- KajMagnus 7y agoNow jQuery is gone (see my other reply just nearby, in this same comments tree). Actually, when I was starting with React, then for a while Talkyard did use both jQuery and React on the same pages (not a good idea, I agree). I was careful to avoid the bugs you have in mind from happening, so that wasn't a problem, however, loading & using both libs wasn't good for performance — just parsing and executing the 30 kb min.js.gz jQuery bundle took maybe half a second? a second? on mobile phones, back at the time (2.5 years ago).
- alharith 7y agoI was a very early adopter of React at my company (fall 2013) and IIRC, using jQuery with React was still in the docs. edit: and it still is today, just a tad updated: https://reactjs.org/docs/integrating-with-other-libraries.html https://reactjs.org/docs/integrating-with-other-libraries.ht...
- KajMagnus 7y agoSame here :- ) Just a bit later, fall / winter 2014. Thanks for the link. I think I saw that page, or sth similar, back then. ... Now I found an old question I posted at StackOverflow about jQuery + React: https://stackoverflow.com/questions/27646347/is-it-okay-to-do-all-these-jquery-things-to-a-react-js-dom-tree https://stackoverflow.com/questions/27646347/is-it-okay-to-d...
- sandGorgon 7y agothe problem is that react and jquery both need ownership of the DOM. if you have code that mixes them, it is recipe for disaster. subtle hidden bugs start creeping up.
- KajMagnus 7y agoAnd performance, see my other comments nearby (jQuery now gone).
- KajMagnus 7y agoAlpine.js looks nice, didn't know about it. Light-weigth React/Vue/etc for just 7 kb :- ) I use Bliss.js, https://github.com/LeaVerou/bliss https://github.com/LeaVerou/bliss for some parts of Talkyard nowadays, where React would be too much. Bliss.js is sth like 3 kb min.js.gz. (But jQuery itself is gone nowadays, it was too large.)
- sandGorgon 7y agoLast commit to bliss seems to be April (and then a few automatic package update commits) I would seriously consider dropping this dependency. React's performance is fairly acceptable.
- KajMagnus 7y agoActually to me, Bliss not getting new features or changes (just maintenance by Lea Verou), is a good thing. Upgrading libs and breaking changes, takes time — stability is nice :- ) I agree that React is fast enough. React is pretty large though, takes a bit time to parse and compile the code, on mobile. And none of its features are needed in this case, and could instead cause conflicts with other libs. What I'd do, if anything, is a custom build / fork of Bliss that removes most of the code, so 3 kb becomes Bliss maybe just 1 kb "Mini-Bliss".
- castis 7y agoMy blind guess is; one hand not know what the other is doing. Ive left projects and come back to find the developer between had done things like, pull in a library to handle slideshows when one already existed. Things like that.
- KajMagnus 7y agoIt doesn't use or load jQuery any longer, however the dependency was still there ... Now I'm removing it. In the beginning, there was only jQuery. .... Then, for a while, there was also Angular, and for a short while, a tiny bit Angular Dart (I got on the hype train?). Then, there was a month removing all Angular things, and switching to React. And then ... Another month removing all jQuery things. There's still a disabled way of laying out a discussion in 2D, using the full width of the screen (nice with a 30'' monitor :- )) and then, for horizontal scrolling, jQuery was used. But all this 2D stuff is disabled nowadays (I like the 2D layout but it's a rarely used power user feature and I was too short of time so had to disable it). (The reason I removed jQuery, and use React only, was to improve performance — just parsing and executing the 30 kb min.js.gz jQuery bundle took maybe half a second? on mobile phones.)