There are a couple of Gulp plugins for JavaScript obfuscation already exist. Unfortunately, they don’t work correctly when you need to obfuscate JavaScript for browser extensions. We’ve tried to find out some solution and finally developed our own obfuscation plugin for Gulp.

Do you know about It is 100% safe JavaScript obfuscator and minifier which can protect your code from analysing and theft. The site has a great web interface with a tons of various options. Also you can download their 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:

It looks horrible. Exactly what we need! But how can integrate this obfuscator in our build process? Grunt users can be relieved. There is js-obfuscator npm package which can be used without any problems. But Gulp fans are not so lucky. There is no such plugin for Gulp. So, we’ve decided to go ahead and develop a such plugin.

Our JavaScript obfuscation plugin for Gulp got a very unexpected name: gulp-js-obfuscator. It is based on the already mentioned js-obfuscator package. This mean that you can use the same options to adjust obfuscation settings of our plugin. Another one useful feature of gulp-js-obfuscator is an ability to skip unnecessary JavaScript files. There is no much sense to obfuscate third party libraries like jQuery.

Take a look at an example of the plugin usage:

That is it! In the next article we will describe a typical scenario for building Google Chrome extensions with Gulp.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]