However, I want to move to the next level, that is taking load off the server and let the client do the processing. Hopefully to be a more JS guy.
My first thought is to request of data off the server, and it just returns key-values which the client will generate the HTML and puck in the values.
There are 3 problems generally:
I find it so much easier to generate the HTML in PHP cause data exchange between the server and HTML is fluid. Unlike returning data in JSON, which I then have to select the DOM that I want, and put in the values eg.
I also find looping through arrays and generating HTML easier than JS?
I find myself using so much of jQuery selector to select the element I'm interested to manipulate and I'm not sure if that's the correct practice (going forward to be a JS ninja). But I'm doing it cause it sure saves lots of characters.
In order to select the elements easily, I tend to give them unique class names as identifier. Again, I'm not sure if that's what a JS Ninja will do.
Going forward (web trend), I would like to know if I should try to put more work to JS?
Also, any ideas or thoughts on how I can overcome my 3 problems stated above?
Is it a sin to return formatted HTML as part of a JSON value? Or should HTML be generated in JS and only read values off the returned JSON when it needs?
Putting frameworks aside (I know there's Backbone, Angular, Can.JS and many more) does anyone really do raw JS scripting? I mean, it is possible but seems extremely wordy.
Lastly, please advice how one would convert a server centric site to a JS centric one?
If what I wrote doesn't make any sense, hopefully you can point some JS centric sites, and explain what approach they are using as an example. Sites that are full featured (say..maybe facebook, twitter, stackoverflow) and not just a TODO web app.