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

How to prevent javascript code from being accessed ?

I am creating a website, and i don't want my clients to view the javascript code and modify them EVEN TEMPORARILY! is there a solution to this?

1 Answer

Steven Parker
Steven Parker
243,657 Points

:point_right: You can't prevent a clever user from viewing the JavaScript.

Someone familiar with the developer tools can always see the code. But you can do things to limit the usefulness of doing so:

  • where possible, move functions to the server
  • always use server-side validations to prevent input tampering
  • minify and obfuscate your code with a tool such as JavaScript Obfuscator

can "clever users" change the existing javascript code? through developer tools?