Jason Knight
1 min readSep 30, 2022

--

The use of an array then a join() is an overhead inducing nightmare. It's bad enough slopping together (garbage) markup in the JavaScript instead of going direct to the DOM (unless you're outputting it server side) without adding slow arrays and memory wasting copies and functions for nothing. Especially all that "push" rubbish. Since you're also slopping it into the markup, the lack of sanitation / escaping worries me as well, but that's why I'd go to the DOM if this is client-side... or run a htmlspecialchars equivalent regex if this is server-side scripting.

The use of DIV+SPAN doing LI's job, span for nothing, DIV doing OL's job, DIV doing H2 or H#'s job, classes for nothing, etc... also not your friend.

Kind of goes to what I'm always saying that people who try to glue together HTML using JavaScript don't know enough basic HTML to be using either.

But what do I know? I think returning a giant garbage string of markup is stupid even server-side (perhaps even more stupid server-side), which is why I generally pass http.response to my template functions so they can response.write() the markup directly.

And this old geezer has been programming since 1978, has absofragginglutely zero clue what you mean by "cook" or "cooking"

--

--

Jason Knight
Jason Knight

Written by Jason Knight

Accessibility and Efficiency Consultant, Web Developer, Musician, and just general pain in the arse

Responses (1)