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
shapes, but that nearly doubles.
mjit-code also all double, and I would expect that at least the latter to not.
<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:
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.
I think there are are two problems here:
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).