Live data from Hacker News

16% of the code on the average site belongs to Facebook

medium.com

41–50 of 54 posts

Re: 16% of the code on the average site belongs to Facebook

#41
post #26
post #24

I've built my service https://urlscan.io to some extent to be able to track the impact of certain scripts / hosts on the overall size of the website. You can find the breakdown by hostname under "Request Stats" on the right. But, for this use case, it would be perfectly sufficient to use the Chrome Devtools and filter by "facebook" for example. Here is a scan where the 200KB Facebook sdk.js is being transferred (62KB…

Facebook's like button code generator tool[1] includes the entire SDK even if you configure it to only show a like button with no other social graph features. I guess there is an argument that having every site that uses Facebook's API having the same .js file will take advantage of browser caching better but it's still irritatingly wasteful. [1] https://developers.facebook.com/docs/plugins/like-button

the configurator on that page generates: 1/ sdk+like button or 2/ just an iframe with no sdk

1/ is better (proper resizing in different locales) but 2/ is always an option and it saves 60K of JS

Re: 16% of the code on the average site belongs to Facebook

#42
post #7

Earlier quoted context omitted.

It's 200KB minified, 60KB gzipped, so not quite that bad but still quite large. It definitely does more than you'd expect from the documentation on a page like https://developers.facebook.com/docs/plugins/like-button , and then there's all the other stuff I noted in OP like it including a ton of polyfills and legacy code. An example feature the SDK gives you is the ability to subscribe to an event that's triggered on…

> subscribe to an event that's triggered once the user successfully adds a Like A.K.A. the "like this page in order to enable the download link below" API. I wish they'd never made it; it has so many evil use-cases and I can't think of a single non-evil one (that wouldn't be better served by just async querying aggregate data.)

This "likegating" is against the terms of use

Re: 16% of the code on the average site belongs to Facebook

#43

Is there a good reason Facebook's JavaScript file for websites is 400K? Is it unoptimised? Is this just what happens in large companies? Does it do more than you'd think? I would have thought they'd have an incentive to make it fast and lean so people could comment and like faster.

It's 200KB minified, 60KB gzipped, so not quite that bad but still quite large. It definitely does more than you'd expect from the documentation on a page like https://developers.facebook.com/docs/plugins/like-button , and then there's all the other stuff I noted in OP like it including a ton of polyfills and legacy code. An example feature the SDK gives you is the ability to subscribe to an event that's triggered on…

There's a certain amount of legacy code, because the SDK supports old browsers. Therefore it needs polyfills. And it cannot rely on, say `if ('JSON' in window){}` because there are buggy polyfill implementations out there. So the SDK needs to bring its own polyfills.

Additionally it cannot just do `Array.prototype.map = ...` because fiddling with the host page's globals is a sin. Hence every post-ES3 method call is wrapped in a local `ES()` function. Oh the joys of third-party javascripting :)

Re: 16% of the code on the average site belongs to Facebook

#44
post #17
post #10

I just use open graph tags on websites, which are more useful, lightweight and makes the link presentable and customisable when shared around Facebook. There's no downside to open graph tags. Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. The number means nothing because your website might be one month old with '2k likes', or two years old…

Makes zero difference to any visitor what that number is. The overall number may have no value (although social capital theory would suggest otherwise), but when a user looks at a Facebook page and sees "5 of your friends Liked this page" with a list of who they are, that has a huge impact on how they think. It's like having a personal recommendation. That's worth a lot. Likes do have value.

That information is better kept within Facebook. If you're already on the page, why does it matter to notice only then that some of your friends like it?

Re: 16% of the code on the average site belongs to Facebook

#45
post #10

I just use open graph tags on websites, which are more useful, lightweight and makes the link presentable and customisable when shared around Facebook. There's no downside to open graph tags. Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. The number means nothing because your website might be one month old with '2k likes', or two years old…

> Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky.

I disagree. Remember those visitor counters on most hobbyist websites from back in the day? Facebook likes are, are their core, that.

It's basically herd mentality.

Re: 16% of the code on the average site belongs to Facebook

#46

Earlier quoted context omitted.

That's gone actually, they removed it a few weeks ago IIRC. I don't use Google though, not sure if it's still enabled in some places. In fact, I'm not really sure what ktRolster is talking about; it is 150KiB, but honestly that's pretty small for a page these days, especially one with any images (today it's a google doodle, so normally it would be about 24KiB smaller).

Here you go, I uploaded an image of the file transfers showing just the html and javascript: https://imgur.com/a/aTpj2

Ahh, now I see. I had cookies disabled, which apparently changes everything. It's something more like 480KiB for me now. Yikes, such a simple page.

I wonder how much is in a typical person's cache though.

Re: 16% of the code on the average site belongs to Facebook

#47
post #10

I just use open graph tags on websites, which are more useful, lightweight and makes the link presentable and customisable when shared around Facebook. There's no downside to open graph tags. Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. The number means nothing because your website might be one month old with '2k likes', or two years old…

Your point is not entirely accurate though. The likes get displayed and used on Facebook which can help and your post to the top of other people's feeds. I don't like them either but you'd be crazy by not integrating it on a website that you're trying to funnel organic, social traffic to.

It's not the website's job to host Facebook-exclusive functionality.

By all means have the basic FB share link, as found on every Youtube video, along with other social media services. But the actual Facebook widget is not what should be installed on websites, and FB should kill it dead.

Sounds like you need a browser extension to handle "liking" the current page you're on. Not all websites have the Like button, so it makes no sense to assume a website Like button is "plan A" in any social traffic strategy.

Further more, websites have many pages. It's impractical to install a Like button for every discrete piece of content everywhere on the site, and everywhere on the Internet.

Facebook Like buttons DO NOT belong on every web page of every site on the Internet, and the widget should go the way of Flash. (I'd sooner keep Flash than FB javascript).

Re: 16% of the code on the average site belongs to Facebook

#49
post #10

I just use open graph tags on websites, which are more useful, lightweight and makes the link presentable and customisable when shared around Facebook. There's no downside to open graph tags. Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. The number means nothing because your website might be one month old with '2k likes', or two years old…

> Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. Google have said Facebook likes aren't treated as a ranking signal but your page showing up on newsfeeds will bring in more likes and more backlinks. > Makes zero difference to any visitor what that number is. It's not any measure of performance or anything. You don't think a large number of…

But what is a "large number"? Not all FB users will click the like button on a website, or expect it to be there, because the website is not a Facebook page. The number of likes is not a traffic measurement, it doesn't represent the website popularity.

I completely understand the newsfeed point, which is why I have no argument against social sharing buttons on websites - the non-scripted kind that link to various services from Twitter to Reddit to FB. If the user wants to share the site, they will use this method, or they may copy the link, or have some other way to like the page such as a browser extension.

"Like us on Facebook" is what Likes are about. You go to Facebook, and you Like something - a post, page or item. It's a Facebook thing, not a "everything in the universe" thing.

Re: 16% of the code on the average site belongs to Facebook

#50
post #45
post #10

I just use open graph tags on websites, which are more useful, lightweight and makes the link presentable and customisable when shared around Facebook. There's no downside to open graph tags. Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. Nobody cares how many likes your webpage has. The number means nothing because your website might be one month old with '2k likes', or two years old…

> Website 'Like' buttons on the other hand, are useless, tacky, cheap and chunky. I disagree. Remember those visitor counters on most hobbyist websites from back in the day? Facebook likes are, are their core, that. It's basically herd mentality.

The old counters recorded every visitor. FB likes record only FB users who are logged in, wish to share the page, and bother clicking the button. Huge difference, no correlation.

As a final thought... At least Twitter invented a word for their sharing action, "retweet". Facebook just stole "like" and "thumbs up". I don't remember those things being up for sale.

Post reply on HN