If I were to encrypt code.js which contains all of the main code of the mod I created, will the mod still function properly in-game?
You can obfuscate it.
Just look up “javascript obfuscator” on Google, or just use this simple website.
There are a lot of them, but they all work pretty well.
You probably could encrypt it, but I don’t get why you would do that, it seems weird to obfuscate mods seeing as anyone can download them, anyway, if you are really that anxious about your code being stolen, feel free to obfuscate it, however, it would be super easy to make an exact replica of your mod by anyone.