math.js implements the error function.
Simply put <script src=https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.3.0/math.min.js></script> in your html header and use math.erf(x) in your script.
https://mathjs.org/docs/reference/functions/erf.html