I just finished an intro to web dev course in my CS program and came away wondering something simple. When should you use JavaScript (client-side) instead of server-side (we used PHP but anything applies) code? Vice-versa as well.
There is no recipe for deciding that. A few notes:
Of course, if your application is a RIA (rich internet app), then you can have logic on the client. So it all depends.
Javascript should be only used to manipulate the UI of the page. You can also do certain validations using it, however, there must be corresponding validation on the server-side. For doing any data manipulation, applying business logic, etc you should always use server side code.
Here are some cases where you will use client-side code:
Cases where to use server-side code:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With