Obfuscation in JavaScript

I love the word obfuscation. It seems to reflect its own definition. To obfuscate something is to make it difficult to understand.

So why would we want obfuscation in JavaScript. Well, let me give you an example. Recently I was working on a project where we had to connect to an online system. The online system did not have the security fully implemented yet, and as a result we had to include some of the details about the system in the JavaScript code. Well, we didn’t want it to be super simple for someone to discover that information. We wanted to hide it a bit. So the solution…we obfuscated that portion of the JavaScript code.

I learned about a couple of sites that help do this. They obfuscate your JavaScript code by moving things around and converting information to Hex. I used both of these locations. I would pass the code through the first location and then pass the results through the second. Technically, someone could figure it out, but it is quite difficult. Drop some code in, obfuscate it, and then see if you can make heads or tails of it.

https://javascriptobfuscator.com/Javascript-Obfuscator.aspx

https://www.daftlogic.com/projects-online-javascript-obfuscator.htm

Author: Steven Hancock

Steven has 20+ years experience in product development and 15+ years using JavaScript. He started learning JavaScript when it was a niche language used for minor affects on a web site. The growth and ubiquitous nature of JavaScript both excites and inspires him.

Currently he is President and lead Trainer at All Things JavaScript, a resource for anyone and everyone that hopes to increase their JavaScript skills.

Steven was the co-owner of Rapid Intake, an eLearning Authoring firm. While there he managed all development and professional service related activities. He was heavily involved in the initial development of Rapid Intake’s main product, which eventual lead to its acquisition in 2011. In addition to JavaScript, Steve has also dabbled in other web technolgies such as ActionScript, ASP, PHP, HTML, and CSS.