When to Use JavaScript and When to Use the Server to Access Facebook Platform

Among the toughest decisions my clients make when working on applications are issues like, “How much of the rendering should they control on the server side? How much should they handle on the client with JavaScript?” In reality, you can do just about everything with JavaScript, making calls back to the server as needed to get dynamic data from your database. You might also have times when you want to control everything from the server, making API calls back to Facebook using a library — like Facebook's native PHP or Python libraries — to make all the calls on behalf of the user. When do you access the API in JavaScript, and when should you do so on your server?

The short answer is, “It's up to you, and it all depends on your needs.” It may be that JavaScript isn't your forte and that you prefer accessing the Facebook APIs in a language such as PHP. Or perhaps It's just the opposite, and you'd rather not touch a server-side language like PHP to make your calls to Facebook. The following sections describe the advantages that I see to using a JavaScript-controlled architecture as well as the advantages that you could gain from a server-side-controlled architecture.

Advantages to a JavaScript-controlled architecture

In some cases, you want to use a JavaScript-controlled architecture. Here are some advantages of doing so:

  • No server administration worries: One advantage that you have to using JavaScript is ...

Get Facebook® Application Development For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.