It is not a secret that many browser extension developers want to protect results of their work from copying. The problem is that Firefox and Google Chrome extensions can be unpacked without any problems. So, anyone can analyze a source code of any extension and investigate its internal logic. Of course, developers don’t like a such state of things and want to protect their intellectual property.

The most common solution is to use some obfuscation tools. But the problem is that the most of obfuscators know nothing about Firefox or Chrome platform API and extensions simply don’t work after obfuscation.

Fortunately, there are some obfuscation tools which don’t have such a problems and can be used to protect your browser extensions from a very nosy programmers. javascriptobfuscator.com is one of them. It has a great web interface with a tons of various options and desktop tool for Windows which can do the same things. Let’s take a look how it can protect your code.

Initial script:

Obfuscated script:

Wow! It looks really messy. It is absolutely impossible to understand something here. And the most pleasant thing is that it will work inside your Chrome extension without any problems.

Alright, we’ve found a good tool. But how to integrate it in the build process of the extension? It can be very annoying to obfuscate each file manually, especially if you’re working on a large project. Now we will assume that you’re using some build automation tools like Gulp or Grunt. To be honest, it can be not necessary to set up a build process for the project which can be completed and delivered in a couple of hours. But in the case of a complex project it is almost necessary.

So, we’ve tried to integrate JavaScriptObfuscator into our Gulp build script. That was a big surprise here. We’ve not found any affordable solutions. So, we decided to write our own JS obfuscation plugin for Gulp. You can read this article to find more deatails about the plugin.