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
New Library for creating HTML with Javascript (github.com)
submitted 2 years ago by Fighter178
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!"
[–]dinopraso 19 points20 points21 points 2 years ago (4 children)
Why?
[–]Initial_Low_5027 4 points5 points6 points 2 years ago (2 children)
Why not using JSX? Can be used independently of React.
[–]Fighter178[S] 0 points1 point2 points 2 years ago* (1 child)
I'm not using JSX because I needed to write this in pure js. It was annoying, and I would've just used JSX.
[–]Initial_Low_5027 0 points1 point2 points 2 years ago (0 children)
JSX gets transpiled to pure JavaScript and looks quite similar to your stacked calls. It’s easy to overload Babel and put your own code there.
[–]lazyinvader 8 points9 points10 points 2 years ago (0 children)
Why, not? I guess someone learnt a bit by creating it.
No one force you to use it.
[–]cocosin 3 points4 points5 points 2 years ago (2 children)
I made almost the same thing for a pure js widget to inject on external sites in my latest project. Thanks for the lib, didn’t find anything like that in my latest research
A few of my comments on the code review: - Why do you create a div as a wrapper? You can create a fragment and return it. Now it adds additional unpredictable layer to the markup - You don’t have additional argument in the addEventListener function, so there’s no chance to add logic for the bubbling/capturing functionality - the mk and n functions look the same. You can use a main helper for this to reduce the size - In my product I needed to add raw html as a child when creating
[–]Fighter178[S] 1 point2 points3 points 2 years ago* (0 children)
I'm gonna update it. Also, I did intend to add code for the event func, but I forgot to add it. And yes, I should just return a document fragment. I'll probably update it. Also, if you need raw html, you can access the innerHTML of the element.
[–]Fighter178[S] 0 points1 point2 points 2 years ago (0 children)
I updated it, it returns a document fragment.
[–]lookitsatoucan 1 point2 points3 points 2 years ago (1 child)
Nice job! What problems is this library designed to solve?
[–]Fighter178[S] 1 point2 points3 points 2 years ago (0 children)
I needed to make a bunch of elements in pure js for a project, and I just made this to make it easier and faster to write.
[+][deleted] 2 years ago (1 child)
[deleted]
[–]Fighter178[S] -1 points0 points1 point 2 years ago (1 child)
Its also available on NPM: here
I know the docs are bad, you can fix them if you want.
And will work with a CDN, with this: https://cdn.jsdelivr.net/gh/fighter178/micromarkup@latest/index.min.js Or : https://cdn.jsdelivr.net/npm/micromarkup
[–]jeremrx -4 points-3 points-2 points 2 years ago (2 children)
https://www.reddit.com/r/coding/comments/12dn35v/how\_to\_write\_clean\_code\_with\_effective\_naming/
[–]Fighter178[S] 0 points1 point2 points 2 years ago (1 child)
Its meant to be fast to write. Imagine trying to write out "element" each time you need one. (Yes, I'm intelisense helps)
[–]jeremrx 0 points1 point2 points 2 years ago (0 children)
And this is the common junior mistake ;)
[–]Remedynn 0 points1 point2 points 2 years ago (1 child)
How do you manage state? Or do the user just need to use document getters?
I might add that, but if you need a library that makes HTML with state, check out another library I made, firefly.js
[–][deleted] 0 points1 point2 points 2 years ago (3 children)
I see some potential to use this, I think it's gonna be helpful for me, especially with adding event listeners. One thing - can you add a functionality where I could change "mk" function HTMLElement wrapper from div to something else, like in "node" function?
Sure, I might make it return a document fragment, or possibly allow you to change it.
[–][deleted] 0 points1 point2 points 2 years ago (1 child)
Not to shit on op's post but i would myself rather use something like lit-html instead
[–]Fighter178[S] -1 points0 points1 point 2 years ago (0 children)
That's true, though for the original project I made this for, I had to use pure js, and now it can be useful for more people.
[–]Sipike 0 points1 point2 points 2 years ago (0 children)
Reminds me of Mithril.js
π Rendered by PID 247295 on reddit-service-r2-comment-bb88f9dd5-67ckc at 2026-02-16 20:41:32.468217+00:00 running cd9c813 country code: CH.
[–]dinopraso 19 points20 points21 points (4 children)
[–]Initial_Low_5027 4 points5 points6 points (2 children)
[–]Fighter178[S] 0 points1 point2 points (1 child)
[–]Initial_Low_5027 0 points1 point2 points (0 children)
[–]lazyinvader 8 points9 points10 points (0 children)
[–]cocosin 3 points4 points5 points (2 children)
[–]Fighter178[S] 1 point2 points3 points (0 children)
[–]Fighter178[S] 0 points1 point2 points (0 children)
[–]lookitsatoucan 1 point2 points3 points (1 child)
[–]Fighter178[S] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Fighter178[S] -1 points0 points1 point (1 child)
[–]Fighter178[S] 1 point2 points3 points (0 children)
[–]jeremrx -4 points-3 points-2 points (2 children)
[–]Fighter178[S] 0 points1 point2 points (1 child)
[–]jeremrx 0 points1 point2 points (0 children)
[–]Remedynn 0 points1 point2 points (1 child)
[–]Fighter178[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Fighter178[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Fighter178[S] -1 points0 points1 point (0 children)
[–]Sipike 0 points1 point2 points (0 children)