title: How to apply CSS styles to content rendered after AJAX call
body: <p>I'm writing an app which grabs a bunch of JSON data via AJAX, then renders the view which is constructed from the same data in an es6 template literal. Really simple version to demonstrate:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let mountPoint = document.getElementById("mountPoint");
  let view = document.createElement("section");
  view.id = "view";
  view.innerHTML = `&lt;section&gt;${returnedAjaxData}&lt;/section&gt;`;
  mountPoint.innerHTML = view;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#mountPoint {
    background: #000000;
  }
  
  #view {
    background: #444444
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;My App&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;section id="mountPoint"&gt;&lt;/section&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Where ${returnedAjaxdata} is the data returned from the Ajax call (not shown here but working fine)</p>
  
  <p>The problem is that "#mountPoint" has a black background but "#view" does not have a grey background. It seems that the CSS file is run before the "#view" renders since it waits for the Ajax data before rendering.</p>
  
  <p><strong>EDIT</strong>
  I know how to change CSS on AJAX success for a specific element. My question is how do I run the entire stylesheet after the AJAX call returns AND the DOM is rendered. For context - the entire app will be inside "#mountPoint" so updating a single element wont help much</p>
  
  <p>One possible solution would be to write the styles.min.css file after "#view" is rendered but that seems hacky... I'm wondering: how does React and other view rendering frameworks do this? They render HTML after the CSS files are read as well right? Is there a good pattern out there for this which I can learn?</p>