Facebook: Sea Cow of the Internet

July 22nd, 2008 8 comments

Update: Schrep (I’m far back right, he’s in the middle…note the ripped shirt, sorry Schrep!) was kind enough to point out that, as of bug 423377 being resolved, Firefox 3 defaults to 6 simultaneous connections.  Modern browsers all use different numbers, the lowest being IE 7 with 2 (all older browsers also use 2).

One of my projects here at Mozilla (and, coincidentally, a past project at Yahoo!) was improving ySlow scores.  ySlow is a utility that measures load time and analyzes page performance, assigning you a final letter grade based on various performance metrics.  It’s a neat little Firebug plugin, and I highly suggest that any web developer install it.

Occasionally I like to play with this tool on other big sites, just to see how many of them actually care about such things.  So I went through and ran ySlow on some of the more common Facebook pages.  Here’s what I found:

With most aspects Facebook does a decent job: with the exception of advertiser scripts and some application-specific code they use etags, minify their JS, and use long expires headers.  What amazed me is the number of JS and CSS files on each page, all listed one after another in the header:

Page JS Files CSS Files CSS BG Images
Homepage (logged out) 5 5 14
home.php 23 24 32
profile.php 26 21 36
photo_search.php 11 7 23
photo.php 18 8 26
friends 15 13 34

And for those curious, here’s the count for the new facebook design (summary: significantly worse):

Page JS Files CSS Files CSS BG Images
home.php 27 24 60
profile.php 45 13 67
photo.php 25 9 46
friends 26 19 57

Really, I can’t think of any context in which 47 external files would be necessary! I understand breaking files up by purpose to make coding and revision management easier, but I wonder if someone at some point considered the speed impacts. I’m fortunate enough to almost always have a broadband connection, but the experience for their dial-up users is probably deplorable. Especially considering that they now localize the site and are pushing to expand overseas, you would think this would be a much higher priority. And don’t even get me started about the lack of spriting!

Here’s how I setup Mozilla’s JS/CSS concatenation (see the Build Process):

  1. Add a configuration setting for site state (example: a flag set to “production” on production servers, “dev” on everything else)
  2. All CSS/JS calls use these flags to decide if they go to the concatenated files or the actual development files
  3. Create a build script that generates the concatenated files (profile.js, photo.js, etc), run before pushing to production

Ironically enough I would bet Facebook already has #1 and #2 setup, since they use Akamai for production servers, and can’t use that for development.

Alternatively they could use the method YUI uses for serving JS files.  Basically call a script that will return the concatenated files.  It’s a less elegant solution, and is heavier on the server, but still better than nothing.

Note that this doesn’t only affect dial-up users.  While broadband users usually have a fast enough connection to offset the slowdown, a large file count is the biggest slowdown for broadband.  This is because of the 2-simultaneous-connection limit that most browsers obey.  From rfc2068:

Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD maintain AT MOST 2 connections with any server or proxy.

Facebook.com is the 8th most popular site on the web, while Mozilla.org is the 258th (note that this is all of mozilla.org, not just addons.mozilla.org).  They should be able to devote a lot more to the tail end of their users, especially considering the residual benefits for their main audience.

Just as bad is their lack of proper fallback for those with JS disabled. For example, if you were to disable JS, you can still login fine, but once you login, head back to facebook.com. That’s right, they use JS to redirect users from their homepage, with no <noscript> fallback, meaning the average joe with JS disabled can easily lock himself out of Facebook.  In addition, pretty much every new feature added since poking doesn’t have a non-JS fallback.  Status updates, “People you may know”, dropdowns, the entire “Friends” page, and so on.  All completely useless.

In the Basement of the Ivory Tower

July 16th, 2008 5 comments

I try not to make posts primarily links to articles, but this article about the truth behind America’s “everybody should go to college” mentality is both enveloping and thought-provoking (the author definitely proves his qualifications as a teacher).

Personally, I’m a little split on the subject, though I lean slightly in the direction of the author. On the one hand, I agree that the ideal that everybody should have a college degree is just that, an ideal. Some people are not able to, or have no reason to, obtain a college degree, and encouraging them to do so is a waste of their time, money, and energy.

On the other hand (and this is a tangent “Professor X” doesn’t touch on), I see and interact with people who haven’t had a college education, or have gone to a local community college at night, and it’s often surprisingly difficult. I’m not referring to intellectual differences, but I feel that going away to college gives you a more open view of the world. It not only exposes you to different cultures and ways of thinking, but shoves you into a hot, crowded room with them. It forces you to eat, sleep, and live with them. If that doesn’t broaden your horizons, I don’t know what will. Those who haven’t experienced this part of the education system I find are often much more naive to the world…they see people as more black and white than they really are. I’m not saying that college is the only place where one can learn these shades of gray, but for many who are born, grow up, work, raise a family, and die in the same place all their lives, this is the only opportunity they have to do so.

If it is idealistic to think that everyone should have a college education, it’s downright foolish to think that everyone should go away to college, and while I agree completely, if we don’t work towards ideals and dreams, how else will we make progress?

Tags:

WordPress Plugin Installation Hackery

July 15th, 2008 5 comments

Update: Full script posted below.

I’m just wrapping up a relatively large project centering around a WordPress plugin.  I’ve gotten a chance to explore the API in depth, and have discovered a lot of nice things and a lot of not-so-nice things.  One of the not-so-nice things was the way plugin activation is handled…it is assumed that, assuming no fatal errors occur, that a plugin was activated properly every time.  There’s no feedback mechanism, no way to pass back a message saying “woa, something’s wrong here”.  So I wrote my own.

Now, this plugin will be installed on one site, and I will be doing the installation, so realistically there’s not too much of a concern.  But I was slightly worried that the plugin made a lot of tables, and that in the future the plugin may be installed on a system that has a table with the same name.  This may be incredibly unlikely, but it’s good to plan.  With that goal in mind I wrote a neat piece of code (see below for the whole script to put things in context, though this piece is the most interesting):
Read more…

Tags:

f8 2008

June 26th, 2008 No comments

Just got my ticket for f8 2008, I’ll be in San Francisco July 23rd, I’m sure I’ll have some interesting notes to share :) .

Tags:

Download Day is Awesome

June 19th, 2008 2 comments

<rant>

Today I ran into an interesting response to Paul‘s post on those who dislike the awesome bar (which I decided not to link to).  The post pulls the following quote from the end of Paul’s well thought-out and harmless article:

So just give it a shot and quit complaining. Yes, it is a complete paradigm shift. But it’s not called the Awesome Bar for nothing; it really is awesome once you give it a chance

And proceeded to call Paul an “asshat” and a “discredit to the Mozilla community”.  Really?  One sentence saying “give it a chance” and all of a sudden Paul’s an asshat?

Normally I would ignore this and chalk it up to people seeking out drama for the sake of snagging pageviews, but it made me realize that most media does this.  The Firefox 3 launch was absolutely amazing: we had 8 million people download our software in 24 hours, 12 million in 48.  It’s unreal!  Yet I’ve seen dozens of posts and articles talking about a minor outage and “howls of derision across the blogosphere”.  Are people that desperate for a negative angle to a story?  I’ve yet to hear one negative comment from people in person (granted, I see a lot of Mozilla employees, but I still see/talk to other non-Moz folk).  The execution had a few hiccups, but the overall project went amazingly well.

This is why I like sites like Hacker News.  The community discourages blowing things out of proportion.  For example, I recently commented on a post entitled Firefox 3 smart bar is just too smart, and it led to an intelligent discussion about the merits of the bar.  My post said basically the same thing as Paul’s, but there’s less hostility towards differing opinions, and it results in the ability to actually discuss things instead of pointless name-calling.

So the next time you’re writing a blog post focusing on a tiny negative aspect of a project, think about the big picture, and if it really matters, or is just a rant to spread negative views that only benefit your pageview count.

</rant>