<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>
<script>
  function katex_render(node, params){
    eqn = node.getAttribute("data-expr")
    katex.render(eqn, node, params);
  }

  document.addEventListener("DOMContentLoaded", function(event) {
    // grab all elements in DOM with the class 'equation' or 'inline-equation'
    var inline_eq = document.getElementsByClassName("inline-equation");
    var eq = document.getElementsByClassName("equation");

    // for each element, render the expression attribute
    Array.prototype.forEach.call(inline_eq, function(el) { katex_render(el, {}); });
    Array.prototype.forEach.call(eq, function(el) { katex_render(el, { displayMode: true }); });
  });
</script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>
<script>
  function katex_render(node, params){
    eqn = node.getAttribute("data-expr")
    katex.render(eqn, node, params);
  }

  onload = function(e){
    // grab all elements in DOM with the class 'equation' or 'inline-equation'
    var inline_eq = document.getElementsByClassName("inline-equation");
    var eq = document.getElementsByClassName("equation");

    // for each element, render the expression attribute
    Array.prototype.forEach.call(inline_eq, function(el) { katex_render(el, {}); });
    Array.prototype.forEach.call(eq, function(el) { katex_render(el, { displayMode: true }); });
  };
</script>

Use 'onload' to add Katex after DOM loaded
Use 'onload' to add Katex after DOM loaded
