DOM Manipulation is Hard

04/17/20191 Min Read — In JavaScript

I realize: I'm accustomed to writing my front end with JSX or hyperscript-helpers. I programmatically generate HTML and stick functions to it instead of separating pure HTML from JavaScript.

And pure DOM manipulation is now hard.

I find it easier to make functions and pass arguments to those functions to generate HTML. "Hard-coding" HTML and trying to use event listeners and then to manipulate the event targets with setAttribute() looks ugly.

Libraries like hyperscript abstract out the weirdness of the Web DOM API and make it easy to work with.

Working with HTML-in-JavaScript feels more seamless to me.

I enjoy thinking in functions instead of HTML.

Vanilla JavaScript has its merits, but using abstractions is also useful.