Search code examples
javascripthtmldomsimple-html-dom

Should I place my HTML inside JS, and innerHTML to .root, just like React.js?


Should I consider

HTML:

<div class="root"></div>

JS:

document.querySelector(`.root`). innerHTML = `{ **html here** }`;

Would this ease my work out make it even worse?


Solution

  • depends on the project. data heavy stuff generating html from js is the way to go... for more static sites, html is just fine.

    I generally don't write more html than this.

    <body id="root"></body>
    <script>
    const root = document.getElementById('root');
    </script>