Nermeen Mattar
Nermeen Mattar

Reputation: 19

Client side scripting VS server side code

I am new to this field. If I want to hide parts of my webpage, should I use client side scripts of server side codes (or both)? Because one of the teachers told me that you can't only rely on Javascript, because people can prevent Javascript by using "Do not allow any site to run Javascript".

Upvotes: 0

Views: 185

Answers (1)

Jason C
Jason C

Reputation: 40406

If the data is sent to the client, the client will always have a way to see it. For example, JavaScript enabled or not, you can always open Chromes developer console and inspect the document, or pick view source from the main menu.

The only way to keep information from a client is to not send it to them in the first place. This has to be done server side.

Still, you should seriously consider asking yourself if you have anything truly worth hiding. For the most part, silly, inexplicable attempts to hide page source just leads to massive user inconvenience, like disabling context menus and such, and never actually works. Never understood why folks thought that was a good idea.

On the other hand, things like authentication and authorization, database interaction, etc. you would want or have to do server side.

As for generating actual content, just for presentation not for the purpose of "hiding" things, generally it's a mix of both, the balance just depends on the application. You'll have to make the call during design and development.

Upvotes: 2

Related Questions