Here's a simple example. If you paste this code in an HTML file and then open that file in a browser, it should render, and with no occurrences of $$
anywhere to be found, so hopefully you can then tweak it to whatever you need.
Not sure why, but I needed to use \\
wherever I found \
on the Katex function support page, so if \\
doesn't work for you, try switching it to \
.
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js"></script>
</head>
<body>
<span id="formula">f(x)</span>
<script>
katex.render("\\int_0^1{f(x)}", formula);
</script>
</body>
</html>