Can I protect my source code if I use webassembly?

I am thinking of how I can protect my browser game from bots. As if I wrote it in JavaScript/TypeScript, everything would be so visible on the surface to a bot creator via dev console, that it's literally impossible to hide any piece of code.

For example, I am creating a tetris-like multiplayer game where two users control moving and rotating bricks to win. The game generates data from the code and uses it to draw bricks on the screen. So, I can look into the app's state to see which brick is next to write a script which would detect where the brick should be moved to.

I never worked with WebAssembly, and I wonder if compiling my source code into bytecode with it is a way to make it more difficult to be looked into. Is this something I should look into to complicate creating a bot?


  • Wasm essentially is abstract machine code. As such, reverse-engineering it is about as easy or hard as reverse-engineering real machine code. It's all a matter of effort.

    There are many good reasons to use Wasm instead of JavaScript, but code obfuscation probably isn't one.