Hacker News new | ask | show | jobs
by djeric3 3248 days ago
Facebook.com does a lot more than show a newsfeed, profiles, and notifications.

  - It contains a fully-fledged messenger application that supports payments, videoconferencing, sharing rich media etc
  - The newsfeed supports interactive 360-degree video, a live video player, mini-games in the newsfeed, and lots of other rich/interactive media
  - It's a gaming platform for 3rd party games
  - It's a discussion forum, groups management system, event planning UI
  - Photo sharing and editing platform, as well as live video streaming tool
  - A platform for businesses to have an online presence (Pages)
  - A peer-to-peer online marketplace (called "Marketplace")
And a dozen other things I can't think of right now. You might say "but I don't use all of those things". That's another tricky part, the fact that every user has a different "configuration" and different types of content in their newsfeed at any given moment, requiring them to be served different sets of JavaScript code.
1 comments

Most of these features are unnecessary until the user tries to play a video, a game, opens a dialog etc.
Right, and that's what happens today, the JS for the secondary functionality is loaded on demand.

Here's what I have in my FB homepage during a random load:

  - Search bar for searching people/groups/posts/pages
  - News ticker
  - Friend requests, Notifications
  - Sidebar ads
  - A rich text editor for sharing my status
  - A newsfeed story with a special "memory - 3years ago" feature
  - Comments & commenting UI under newsfeed stories
  - Suggestions for "People You May know"
  - A video auto-playing a clip from a friend, with capability to auto-select between tracks of different video quality based on bandwidth (including bandwidth estimator code)
  - And probably a dozen different A/B experiments that I'm a part of
It takes a lot of code just to render all these UI elements. If I interact with any of them, additional code is loaded (you can see this in the Network monitor).

This homescreen UI is as rich as any desktop application and requires no less code to render. The problem being addressed in this proposal is that a native version of this app would start a lot faster than the web version. And that's because a browser will parse all the code files loaded on startup in an app (inefficiently, by necessity), but a native app will only read the code for the code paths that are actually executed.

Basically, O(code executed) is a lot better than O(all files containing code that is executed). And this proposal features a more parser-friendly encoding and change to the parsing semantics.