by slver · 5y ago · 0 comments
Maybe a bigger question is why not have this as a JS library, but its own language. Because it's kind of almost there (here using jQuery):
<button _="on click toggle .big-text">
Toggle the "big-text" class on me on click
</button>
<button onclick="$(this).toggleClass('big-text')">
Toggle the "big-text" class on me on click
</button> <button onclick="this.classList.toggle('big-text')">
Toggle the "big-text" class on me on click
</button>then I realized I didn't want to deal w/ async/await or setTimeout, and off I went...
for async transparency the hyperscript runtime looks at the results of every expression and, if it is a promise, resolves the promise before allowing the parent expression to continue evaluating
so you don't actually need to think about (or know) if an expression returns a promise or not, the runtime takes care of it for you, a very unique feature that does require a runtime. And if I'm gonna make a runtime, I'm gonna make a language too
it's also slow as molasses, if you are trying to write a bitcoin miner, for example
but for front end scripting, it usually doesn't matter and the convenience is worth the runtime costs
at least that's the theory
lets find out