vanilla js conditional rendering

are there other ways? The downside here is that it took six lines of code to render what took one line with innerHTML. What is the purpose of this D-shaped ring at the base of the tongue on my hiking boots? Super. JavaScript Engine. But by golly, were going to try anyway, and its going to be interesting. But if you are building something like SPA behind login then it is much easier (and reloading whole pages in SPA is not a thing you want, right). You can learn about rendering HTML with no libraries and using vanilla JavaScript/TypeScript in my other article The Sample App Here is the app I'll demonstrate in this article. The upside here is that the code has more typing, and it relies on the API. What's the Value of lit-html In this way all html, js, and css for a single page/interface is rendered server-side up front with no delay. I wish you would update https://css-tricks.com/reactive-uis-vanillajs-part-1-pure-functional-style/ article to add HTML escaping. Althought this article has inmense value and all of this is valid React, when an application gets big, using live vanilla javascript to condition the render adds complexity and you start building an enviroment very prone to errors later, good practice will be create a component that handles the condition taking it as a prop and returns the children or null, and reuse it across the app, making your render entirely declarative instead of imperative has been an old trade in San Francisco since the begining of React.. truth is you can call it how ever you want,, but make sure the component do that.. back in the pre-hooks days ppl use to do it using a HOC . Template Literals basics. If youve ever used a templating engine like Handlebars or Swig, their syntax looks pretty similar to function-style React code. Well start with the simplest logic: if-else. Another technique is to create a