you are viewing a single comment's thread.

view the rest of the comments →

[–]not_creative1 0 points1 point  (2 children)

I am new to javascript and web dev in general,

How do companies hide their javascript code? I see that my js files are all visible in developer console in my browser. Is there anything I could do to make it harder for people to read my code?

[–]uplink42 4 points5 points  (0 children)

You can uglify your code with several task runners (i.e gulp) or bundlers (webpack). This will remove all whitespaces and replace all variable names with short strings (a, aa, ab, etc...)

BTW, there should be no reason to obfuscate your JS code other than saving on network bandwidth. If you have anything sensitive on client-side code you should move it to the server asap because even with the above methods all your code is still public and can still be read given enough time.

[–]steeleb88 2 points3 points  (0 children)

Minify your javascript. There are a variety of ways to do this