Social Plugins’ Memory Usage
Dietrich recently posted about the memory usage of social plugins, and I found the results rather surprising because, at least in the case of Facebook, I didn’t think it ever loaded enough code to consume 20+MB of memory.
When I first learned about social plugins, I thought that they were a really cool idea and thought that they had a lot of potential. If they use a ton of memory though, I feel like it’s a bit of a deal breaker to using them. So, being the curious engineer that I am, I decided to test this out myself. I conducted these tests in a new Firefox profile and I was not signed into Facebook (to try and replicate the experience Dietrich had).
One Like Button
For my first test, I had a very simple page for the default like social plugin pointing to my site.

One like button doesn’t seem to add much, which is good!
Two Like Buttons
The next test I tried was duplicating the like button so it showed up twice. This code is a bit naive since I duplicate a <div> element with the same id and don’t need to include the JavaScript twice. However, it shows what someone who would just copy and paste will end up with, which I think is valuable.

As you can see, memory usage nearly doubled. This is a bit surprising since the exact same JavaScript is included. I would expect there to not be any additional shapes, but that nearly doubles. scripts and mjit-code also all double, and I would expect that at least the latter to not.
A more interesting version of this test would be to not include the JavaScript twice, and just add one additional <fb:like> button that doesn’t like the same url.
Interestingly, memory usage did not change significantly from the duplicate resource case! So, what exactly is going on here? This page ends up loading four additional resources:
| File | HTTP Status | Size | Mime Type |
| all.js | 304 | 143KB | application/x-javascript |
| login_status.php | 200 | 58b | text/html |
| like.php | 200 | 33KB | text/html |
like.php | 200 | 33KB | text/html |
That is 209KB of HTML and JavaScript that is being sent for two like buttons. Something tells me that part of the problem here is that Facebook is sending more than it needs to for this (I did not look into exactly what was being sent). The good news is that 143KB comes from the browser’s cache.
Send Button
The last test I did was the send button pointing to my website.
Given that the like button test includes a send button as well, I’m not surprised to see that this used even less memory.
Summary
I think there are are two problems here:
- Firefox should create less shapes and do a better job of not duplicating the same JavaScript code in a given compartment.
- Facebook needs to send less data down for their social plugins. I have a hard time believing that that much JavaScript is needed in order to display a like button, a share button, and a faces of your friends who have liked a page.
It’d be interesting to see how these numbers change when you are logged in, but I don’t have time to do that analysis. I’ve provided all the code and steps I used to get these results, so it shouldn’t be too hard for someone else to come along and do that if they are interested. Another interesting test would be to see how the Twitter and Google+ integrations break down too (but I leave that as an exercise for the reader).
Changes
I’m going to write something that will probably surprise you. I say this because it sure surprised me when I realized I was even considering what I’m doing a possibility. I’m going to be moving on to something a bit different in the mobile space, and it’s going to be a different kind of challenge for me.
June 1st will be my last day at Mozilla. I’ve learned so much over the years working there, and choosing to leave was the hardest decision I’ve had to make. I do not intend to disappear from the project, however, but my activity level will decrease. Feel free to continue to send review requests my way and cc me to bugs you want my opinion on, and I’ll do my best to reply in a timely manner.
So long, and thanks for all the fish.
[un]Presidents Day
Last week for Presidents Day, a group of us went around San Francisco to streets with the name of past presidents. Just going to those streets would be boring, of course, so we decided to film ourselves doing things that the given president did not do. It sounds boring, but if you are any sort of history buff, this video may amuse you.
It turns out that SF has a lot of streets with the name of past Presidents, so we spent about six hours walking from street to street. It was a lot of fun though; the weather was great, the people were great, and we got an awesome walking tour of the city.
Bluetooth Tethering with the N900 and T-Mobile
I’ve been spending the last few train rides to and from work every day trying to figure out how to tether my N900 to my laptop. While Firefox Mobile is nice, there are some things my desktop does better. I first tried using the PC Suite from Nokia, but that wasn’t successful (it apparently doesn’t support the N900). I then tried JoikuSpot, which is in beta. Sadly, I encountered the “phone reboots when clients connect” bug. However, if they fix that, that piece of software looks very promising. I finally went down the road to Bluetooth Networking.
In order to pull this off, you’ll need to get a handy little application from the Application Manager. Under the Network section, look for “Bluetooth Dial-Up Networking” in the Extras repository. After you install that, you will want to restart your device. Next, pair your N900 with you laptop (this varies per operating system. I used Windows 7 and these instructions will assume that). After pairing the device, add a new Dial-Up connection on that modem. The phone number will be *99# and you will leave the user name and password blank. Save the connection, but cancel it when it tries to dial (it will fail anyway). Now, launch the device manager, and find the Bluetooth modem that should have been installed when you paired the N900 to your computer. Open its properties, and go to the Advanced tab and set the Extra initialization commands to at+cgdcont=1,"IP","epc.tmobile.com". After this, you should be able to connect to the Internet though your phone.
To prove that it works, I wrote this on the train, and I’m posting while still on the train. :P
I found this particular wiki page to very useful in setting this up, but I found translating the instructions to Windows 7 to be a bit difficult at times.
25 Random Things About Me
I’ve been tagged a number of times by the “seven things” and now the “25 things” meme going on around the Internets. I figure that 25 > 7, so 25 things must be a superset of seven things. Hurray for killing two birds with one stone.
I’m supposed to put the “rules” here, so here they are:
Once you’ve been tagged, you are supposed to write a note with 25 random things, facts, habits, or goals about you. At the end, choose 25 people to be tagged. You have to tag the person who tagged you.
Taggers:
(maybe more – I’ve been putting this off for a bit)
Now for 25 Things:
- I love to learn new things.
- I’m oblivious to a lot of things in life. Some people equate that to me not caring, which is mostly wrong.
- I’m shy, but if you know me, you might think I’m lying.
- At one point, I forced myself to not have an opinion on a lot of things. This is now pretty natural. It is how I reduce stress in my life (don’t sweat the little stuff). As a result, I sometimes say that apathy is my anti-everything.
- I love my job. I really really do.
- I have never been to a concert. Ever.
- I only drink mixed drinks and wine. With that said, I barely ever drink.
- I love to read Science Fiction, but never make time to go get a book to read. Once I get the book I tear through it though.
- I have an incredibly strong inability to lie. My only defense is not answering a question, or omitting information.
- I can’t cook. I’m working on fixing that.
- When I was young, I wanted to be an astronaut. I even went to space camp. Yes, it was awesome.
- If you ask me a direct question, you’ll get an honest and sincere answer. You may also not like the answer. Or, you’ll get no answer (see #9).
- I like random. I try to do something random every day. Keeps me on my toes.
- I always have too many projects I’m “active” in. I’m working on changing that to make my life more manageable.
- I have officiated soccer since I was 12. I don’t know why, but I like doing it.
- I love humor. I employ it as often as possible (goes great with #13).
- I love running. I don’t get to do it often enough.
- It’s easy to gain my trust, and it’s easy to lose it. Getting it back is near impossible.
- I’m generally open about myself, but there are many things that I am extremely reserved about.
- I am essentially blind without contacts or glasses.
- I don’t drink coffee. This tends to surprise people.
- I have been on fire. Literally.
- I often say things without thinking. Hilarity ensues.
- I’m not big on talking on the phone. This probably has something to do with #23.
- I love living in California, but it’s made me soft when it comes to fluctuations in the temperature.
Now for the folks I’m tagging. List of names ordered randomly by my computer. For the record, 25 people is a lot of people.
- Rachel Brown
- Alex Vincent
- Ben Newman
- Nicki
- Mike Connor
- Robert Chitoiu
- Dan Witte
- Mike Haslett
- Heather Wilsher
- Courtney Brooks
- Stephanie
- Andy Cross
- Cesar
- Jason Wojciechowski
- Justin Scott
- Robyn Brooks
- Stevie Staeger
- fantasai
- Kate Jones
- Matt Martin
- Blake Kaplan
- Paul Hayward
- Emily Samuels
- Heather Widgren
- Matt Poling
(If you want your last name removed from my website, just let me know.)





