actually somebody even cross-compiled pocketsphinx to javascript with emscripten for this purpose:
https://syl22-00.github.io/pocketsphinx.js/live-demo.html
this works pretty well - all in the browser, especially if you drop in some better acoustic models.