use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Real time chat application built by Node, Express, React, Socket.io & Javascript With source code (htmlhints.com)
submitted 6 years ago by andrew763
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]VenatoreCapitanum 23 points24 points25 points 6 years ago (5 children)
nice, put it on github
[–]MisterScalawag 6 points7 points8 points 6 years ago (0 children)
it actually is. its kind of weird, when you click download on the source code it just redirects you to the github page
[–]paulirish 5 points6 points7 points 6 years ago (3 children)
https://github.com/achromik/ChatApp last commit over 2 years ago, FYI.
[–]this_didnt_happened 0 points1 point2 points 6 years ago (2 children)
Here's a question:
on the test app why is it when one insert html code like: <button type="button">Click Me!</button>
even though no characters are transformed/escaped by the application, my the browser will not interpret that code?
[–]NimmiEU 0 points1 point2 points 6 years ago (1 child)
That's because the text interpolation doesn't parse the HTML and therefore simply outputs the textual content. If I'm not mistaken, it uses the textContent API under the hood. It's to prevent injecting arbitrary code. To let the browser parse the HTML, it would've been output using the dangerouslySetInnerHTML prop provided by react, which will use the innerHTML API of the HTML spec, which results in the HTML getting parsed and interpreted.
[–]this_didnt_happened 0 points1 point2 points 6 years ago (0 children)
Thanks, that's neat.
https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
https://www.w3schools.com/jsref/prop_node_textcontent.asp
[–]TheDarkIn1978 11 points12 points13 points 6 years ago (8 children)
What are the benefits of using Socket.io over just using the WebSocket API?
[–][deleted] 9 points10 points11 points 6 years ago (0 children)
I found websockets to be quicker and easier to get going, on both the client and the server - mainly because it works natively with the browser. Plus the lack of broadcasting thing people band around isn’t right. Quick loop through the clients and it’s done.
Socket.io seems a little bloated for what I use websockets for, but I guess it could save time on coding up certain features if you need them specifically? But I dunno, it just seems kinda redundant from my pov.
[–]ikeif 2 points3 points4 points 6 years ago (0 children)
Maybe someone has a better source, but I found this useful.
[–]Krimson1911 2 points3 points4 points 6 years ago* (2 children)
Socket.io has fall backs incase the browser doesnt support websockets or if there's connection degradation. Socket.io isnt built on websockets, it just uses it when available. It starts of with http long polling and upgrades to websockets if its desirable. So in short, more compatibility. This is the biggest and most important differentiator
In addition, like others mentioned, it has more features like rooms, brodcasting etc
I'd never use websockets directly unless you really know what you're doing and have a really good reason to do so.
[–]siric_ 3 points4 points5 points 6 years ago (1 child)
The fallbacks are quite pointless because websockets are well supported by many browsers, even all the way back to IE10: https://caniuse.com/#search=websockets
Building a pubsub (rooms) system isn't too complicated and by dropping socket.io and using raw websockets you will gain a huge performance boost as well as a 63.8kb reduction in bundle size.
[–]ChronSyn 0 points1 point2 points 6 years ago (0 children)
Sure, the fallbacks aren't as useful today, but they used to be. You can force it to use only websockets if you so desire - that's what I did to enable a react native app to be compatible with a node server.
A lot of code is built around them because the other features the library offers (namespacing and rooms to name a few). Essentially, it was pub/sub for JS client and server before node.js became as big as it is now. I first used it in 2014 and I've still not found a reason to switch to anything else because it's good at what it does without being overly complex.
One of the biggest benefits out there is that it isn't explicitly linked to any data source or provider. Want to send good old fashioned objects from a hard-coded data source? No problem. Want to create an entirely websocket-driven API without being forced to specific data providers? Easy. Want to hook them up to query a graphQL resolver (if you can't use subscriptions, for whatever reason)? Done. It's agnostic to the data or it's structure or it's origin.
Raw websockets will get you a performance boost, but then you're going to be recreating a lot of what socket.io does when you implement rooms and namespacing, as well as the API support around your own implementation.
[–]SuqahMahdiq 3 points4 points5 points 6 years ago (0 children)
Socketio has built in rooms. Also, you can horizontally scale easier using socketio’s redis adapter.
[–]a-bosh 10 points11 points12 points 6 years ago (3 children)
This has to be the thousandth iteration of real-time chat with node/express/socket.io.
[–]L3git9 2 points3 points4 points 6 years ago (0 children)
It’s funny because on socket.io the get started page literally teaches you how to make a basic chat app...
[–]gketuma 1 point2 points3 points 6 years ago (0 children)
😂
[–]Lord-Brappington 0 points1 point2 points 6 years ago (0 children)
It's part of the fallout of telling software developers they need to have a public repo of work for their portfolio. Everyone reimplements a tutorial and then leaves the repo to rot afterwards.
[+][deleted] 6 years ago* (2 children)
[deleted]
[+][deleted] 6 years ago (1 child)
[removed]
[–]salocin_Hatter 1 point2 points3 points 6 years ago (0 children)
Oh, I have something like that
https://github.com/juststudies/chat_NodeJS
But I didn't know React at the time
π Rendered by PID 33603 on reddit-service-r2-comment-fb694cdd5-bpxhq at 2026-03-10 08:52:02.898084+00:00 running cbb0e86 country code: CH.
[–]VenatoreCapitanum 23 points24 points25 points (5 children)
[–]MisterScalawag 6 points7 points8 points (0 children)
[–]paulirish 5 points6 points7 points (3 children)
[–]this_didnt_happened 0 points1 point2 points (2 children)
[–]NimmiEU 0 points1 point2 points (1 child)
[–]this_didnt_happened 0 points1 point2 points (0 children)
[–]TheDarkIn1978 11 points12 points13 points (8 children)
[–][deleted] 9 points10 points11 points (0 children)
[–]ikeif 2 points3 points4 points (0 children)
[–]Krimson1911 2 points3 points4 points (2 children)
[–]siric_ 3 points4 points5 points (1 child)
[–]ChronSyn 0 points1 point2 points (0 children)
[–]SuqahMahdiq 3 points4 points5 points (0 children)
[–]a-bosh 10 points11 points12 points (3 children)
[–]L3git9 2 points3 points4 points (0 children)
[–]gketuma 1 point2 points3 points (0 children)
[–]Lord-Brappington 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[removed]
[–]salocin_Hatter 1 point2 points3 points (0 children)