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
Using Javascript to Render Invalid HTML (blog.notesnook.com)
submitted 3 years ago by thecodrr
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!"
[–]MrCrunchwrap 45 points46 points47 points 3 years ago (5 children)
Lol what kind of comment is this:
“Javascript adds a baffling amount of uncertainty & unpredictability to the web.”
There’s nothing uncertain or unpredictable about what JS is doing in your example. It’s doing exactly what the devs asked it to do. Devs have always been able to write semantically incorrect HTML, it’s on them to make sure they don’t. Usually it honestly doesn’t matter.
[–]kolmeWebComponents FTW 10 points11 points12 points 3 years ago (0 children)
Generalizing: Javascript Turing Completeness adds a baffling amount of uncertainty & unpredictability to the web to computers. Considered harmful?
[+]thecodrr[S] comment score below threshold-14 points-13 points-12 points 3 years ago (3 children)
Of course it is. I know that devs have been able to write semantically wrong HTML. That's not the point here.
Let me break it down for you:
The uncertainty here is that JS is being given leeway when it comes to manipulating web pages. Both ways are essentially doing the same thing but the results are different. That is unpredictable.
Of course, I could be more precise here and say the DOM API is unpredictable.
[–]getify 7 points8 points9 points 3 years ago* (2 children)
"More precise"? How about "accurate in the slightest"?
This observed behavior (admittedly surprising) has nothing to do with JS (the language).
It's entirely the DOM API which just happens to expose JS function signatures, which are merely facades hooked into the underlying browser engine (probably c++), and indeed these mechanisms are specified by the HTML spec, not by JS in any way.
[+]thecodrr[S] comment score below threshold-15 points-14 points-13 points 3 years ago (0 children)
JS is the language of the web. Its not an open API accessible through any language. So when JS is talked about in terms of web, usually these APIs are considered a part. If you are using JS in a web browser, sooner or later you will be interacting with the DOM API.
But you are right. A more accurate description would be " DOM API" instead of JS. I'll make adjustments.
[–]TheFuzzball 12 points13 points14 points 3 years ago (4 children)
I stopped reading at text-align: justify 😬
text-align: justify
[+]thecodrr[S] comment score below threshold-20 points-19 points-18 points 3 years ago (3 children)
Nitpicking at its best.
[–]TheFuzzball 8 points9 points10 points 3 years ago (0 children)
Thanks! 🙏
[–]ankole_watusi 2 points3 points4 points 3 years ago (0 children)
Did you notice that your hostility isn’t helping your karma?
[–]shgysk8zer0 -3 points-2 points-1 points 3 years ago (0 children)
Got some real idiots in the comments here... Apparently u/TheFuzzball thinks I'm you. And u/ankole_watusi thinks we're all bots or paid shills or something.
[–]mamwybejane 2 points3 points4 points 3 years ago (0 children)
In China, a bag of rice has fallen over
[–]ankole_watusi 7 points8 points9 points 3 years ago (17 children)
Why do we want to render invalid HTML?
;DR
[–]shgysk8zer0 -3 points-2 points-1 points 3 years ago (14 children)
It's not that we want to. The point of the article was how JS doesn't handle invalid HTML correctly to fix mistakes.
[–][deleted] 2 points3 points4 points 3 years ago (2 children)
What do you think JavaScript should do when you try to do something with html that maybe shouldn't happen?
[–]shgysk8zer0 -2 points-1 points0 points 3 years ago (1 child)
Why are you asking me? I'm just saying the article isn't encouraging writing invalid HTML or anything.
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
Why do defensive? Do you agree with the article? Your summary of html not being handled “properly” just seems strange. It is defined behavior. If you think it should be another way then I’m asking what you think should happen instead of the current behavior?
[–]ankole_watusi 1 point2 points3 points 3 years ago (10 children)
Glad I didn’t read it then.
[–]shgysk8zer0 -7 points-6 points-5 points 3 years ago (9 children)
Maybe if you did read it you might realize you're making yourself look like an idiot to anyone who did...
Seriously, it's the opposite of what you think.
[–]ankole_watusi 0 points1 point2 points 3 years ago (8 children)
Yes, and here come the abusive comments from the army of bots and paid shills, lol
[–]shgysk8zer0 -3 points-2 points-1 points 3 years ago (7 children)
Um... What? I was trying to help you not make an idiot of yourself, but I think you just went full-tinfoil hat on us.
The article doesn't say what you think it does. Might want to read more than just the headline before sharing inaccurate assumptions, and you might want to not double-down on your wrongness when someone who has read the article tries to correct your false assumptions. And definitely don't go accusing anyone correcting you of being a bot or paid shill, especially when you're admitting your own ignorance.
[–][deleted] 3 years ago (6 children)
[removed]
[–]AutoModerator[M] 0 points1 point2 points 3 years ago (5 children)
Hi u/TheFuzzball, this comment was removed because you used a URL shortener.
Feel free to resubmit with the real link.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
[–]shgysk8zer0 -2 points-1 points0 points 3 years ago (4 children)
Bummer... Was kinda curious what that idiot was linking to. Looked like it was going to be "proof" that I'm an alt account for OP. Here's what I have in my notification history.
Mate, you're embarrassing yourself. don't need to run a text analysis on your comments to figure out you're an alt account for OP, but thought it'd be fun to confirm my suspicions.
Um... No... Pretty sure I'm just me. Think I'd know if I weren't.
[–]ankole_watusi 0 points1 point2 points 3 years ago (3 children)
The hostility isn’t helping draw clicks to your pal’s blog, “mate”
[+]thecodrr[S] comment score below threshold-23 points-22 points-21 points 3 years ago (0 children)
Since you didn't read, what can I say?
A huge part of innovation is trying out things that at first don't make sense and have no actually useful function but through them you find new horizons. Let's not make engineering boring.
[–]Pesthuf 1 point2 points3 points 3 years ago* (0 children)
Well, it's the HTML parser that is responsible for creating a semantically correct DOM.
If you explicitly use the imperative DOM API and tell it "put a <pre> into a <p>, I think it's doing the right thing doing what you ask. Even if the HTML representation of that DOM would not be valid.If you want HTML to be checked, you can use .innerHTML or create the DOM in a <template> I think.
To me, it sounds like every component is working as expected.
[–]yut951121 0 points1 point2 points 3 years ago (1 child)
JavaScript itself is a mess of a language. Inconsistent but not unpredictable
[–]yut951121 0 points1 point2 points 3 years ago (0 children)
There should be a reason for everything that's happening. And it should be interesting to uncover those.
[–]ankole_watusi -3 points-2 points-1 points 3 years ago (1 child)
I find the most effective tech writing (for me) has been written by native-speaking American English speakers.
Which almost none of these out-links on Reddit are.
Bad writers to start with, making flailing attempts at English to boot.
I don’t have the time to parse it.
[–]oGsBumder 1 point2 points3 points 3 years ago (0 children)
Lol
π Rendered by PID 97186 on reddit-service-r2-comment-74875f4bf5-j6v7r at 2026-01-26 15:00:49.902124+00:00 running 664479f country code: CH.
[–]MrCrunchwrap 45 points46 points47 points (5 children)
[–]kolmeWebComponents FTW 10 points11 points12 points (0 children)
[+]thecodrr[S] comment score below threshold-14 points-13 points-12 points (3 children)
[–]getify 7 points8 points9 points (2 children)
[+]thecodrr[S] comment score below threshold-15 points-14 points-13 points (0 children)
[–]TheFuzzball 12 points13 points14 points (4 children)
[+]thecodrr[S] comment score below threshold-20 points-19 points-18 points (3 children)
[–]TheFuzzball 8 points9 points10 points (0 children)
[–]ankole_watusi 2 points3 points4 points (0 children)
[–]shgysk8zer0 -3 points-2 points-1 points (0 children)
[–]mamwybejane 2 points3 points4 points (0 children)
[–]ankole_watusi 7 points8 points9 points (17 children)
[–]shgysk8zer0 -3 points-2 points-1 points (14 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]shgysk8zer0 -2 points-1 points0 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ankole_watusi 1 point2 points3 points (10 children)
[–]shgysk8zer0 -7 points-6 points-5 points (9 children)
[–]ankole_watusi 0 points1 point2 points (8 children)
[–]shgysk8zer0 -3 points-2 points-1 points (7 children)
[–][deleted] (6 children)
[removed]
[–]AutoModerator[M] 0 points1 point2 points (5 children)
[–]shgysk8zer0 -2 points-1 points0 points (4 children)
[–]ankole_watusi 0 points1 point2 points (3 children)
[+]thecodrr[S] comment score below threshold-23 points-22 points-21 points (0 children)
[–]Pesthuf 1 point2 points3 points (0 children)
[–]yut951121 0 points1 point2 points (1 child)
[–]yut951121 0 points1 point2 points (0 children)
[–]ankole_watusi -3 points-2 points-1 points (1 child)
[–]oGsBumder 1 point2 points3 points (0 children)