views:

133

answers:

3

I noticed that like Google Email, FB's source code shows nothing but Javascript. Why do they use JS to write the page?

+3  A: 

Because their pages are extremely dynamic; most of the content has to be constructed dynamically.

Marcelo Cantos
I agree. And now that all of the new browsers are bragging of "2x faster javascript," it probably loads faster than static HTML.
Evan Mulawski
@Evan Mulawski I rather doubt that. They're loading in HTML via JavaScript, the browser still has to fetch and render it.
ceejayoz
@Evan: That's not a silly suggestion at all, but in practice, you still have to fetch enough data to meaningfully populate the DOM, which, combined with the cost of dynamic generation and rendering, probably keeps plain HTML in pole position — at least for now.
Marcelo Cantos
A: 

All their content is populated using AJAX giving it a dynamic and desktop-ish look and feel (aka the instant messaging features)

Sydenam
+2  A: 

this allows them to render pages extremely fast. They just load some javascript to render everything on the screen and then load the rest.
They name it BigPipe. You can read more here http://www.facebook.com/note.php?note_id=389414033919
pretty interesting reading.

Eldar Djafarov