Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Mike Gugliuzza
Mike Gugliuzza
8,497 Points

Javascript code cypher?

Lately I've been looking at the frontend code of different websites I use every day to better understand how they work. However, when i find the website's javascript file from the Chrome Sources tab, I almost always encounter javascript that contains functions and variables that are only defined by letters. I spoke briefly with a javascript developer on this and he mentioned something about how alot of times developers will use "cyphers" to disguise their code, making it harder for other developers to copy. Is this true? if so, what are these cyphers actually called and where can I learn more about them?

Thanks!!

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Mike Gugliuzza,

The term 'cyphers' (ciphers) isn't correct, what this is referred to is obfuscation. See the meaning below.

the action of making something obscure, unclear, or unintelligible.

Developers like myself use obfuscation in production environments to cut code size down, improve loading times and ultimately, keep our code as minimal as possible for the end-user. This is extremely common practice and isn't designed to hide or protect code that another person has written.

An important point to note on this topic is that JavaScript can't be 100% hidden from the end-user, obfuscation is aimed at improving the overall experience in browsers by getting them to do the least amount of work possible to produce the best feature set for the end-user.

You can find an in-depth answer on Stack Overflow.

Hope that helps!

Mike Gugliuzza
Mike Gugliuzza
8,497 Points

Thanks Chris! That helps alot... much appreciated.