Page_Load vs Client Side Event and Startup Script

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
GT73
User
Posts: 415

Page_Load vs Client Side Event and Startup Script

Post by GT73 »

what are the differences between these options?
Client side event and Startup Script are client side (jQueryPlugin) while Load_page is server side?
Which is preferable to use to hide / display and enhance the fields when loading the specific page, especially when the options are many? fose sever side is safer from loading errors js?
Thank you


sangnandar
User
Posts: 980

Post by sangnandar »

Here's the thing:

  1. PHP outputs HTML
  2. Browser parse that HTML into DOM.
  3. Client scripts manipulates DOM.

Client scripts (be it startup scripts or else) is the easiest solution, it's the panacea, because the DOM is already there, you can do whatever you wanna do. The caveats: re-layout page using client scripts is bad idea.
For example:
$('.content-header').hide(); // hide table caption
The whole page will "jump" when the element is being hide. This is a distraction, not good for user experience. So whenever you can avoid client scripts that change page layout after it was outputted. You should never change anything once the page was outputted.
Re-styling element using client scripts is also bad idea. Whenever possible use css.

Bottom line:
Whenever possible maximize server side first, Page_Load() server event is just one of them.


Note that there actually no such thing as "server event". PHP is not event driven. It is called "server event" for the ease of thinking because nowadays event-driven is the common way of thinking. Technically it should called "server sequence", sort of.


Post Reply