Live data from Hacker News

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

medium.com

21–30 of 54 posts

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

#21

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.

You should check out Google's homepage sometime. One wouldn't expect that such a simple front would hide so many k of Javascript, but I guess it does a lot.

Well, there is that instant search feature that starts showing results once you start typing.

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

#22

Earlier quoted context omitted.

You should check out Google's homepage sometime. One wouldn't expect that such a simple front would hide so many k of Javascript, but I guess it does a lot.

Well, there is that instant search feature that starts showing results once you start typing.

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).

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

#23

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.

You should check out Google's homepage sometime. One wouldn't expect that such a simple front would hide so many k of Javascript, but I guess it does a lot.

On my 2016 MBP Google keeps a constant 20% load on a single core. Sometimes it's even up to 60%. I really don't know what Google is doing there.

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

#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 gzipped) just to display some like buttons. Repeat for other networks like Twitter (114KB) and Google: https://urlscan.io/result/fa422ac0-3b2c-4ba7-a182-31921cc61e.... Remember: Even if you don't mind the transfer of 200kB, that volume of JavaScript will take some time to parse, especially on mobile.

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

#25

Earlier quoted context omitted.

Well, there is that instant search feature that starts showing results once you start typing.

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

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

#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

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

#28

Earlier quoted context omitted.

I think most people would consider HTML and CSS "code", too. Why would you not count HTML if it's in its own file, but assuming you would count it if it was JSX returned from a React component?

Probably because technically HTML isn’t so much code as it is a markup language

This seems intuitively to be the case but I wonder what others think. Neither HTML not CSS have your regular programming language constructs like loops and state and what have you. I sometimes teach very basic web tech to arts/humanities students and I tend to make a static versus dynamic distinction for them between HTML/CSS on the one hand and JS on the other because to them it's all "codey stuff" but to me there's an important distinction. I'm happy to take on board other perspectives here.

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

#29
post #15

Earlier quoted context omitted.

Was the title changed? As it is, it clearly says '16% of the code', and to me that does imply only the javascript.

I think most people would consider HTML and CSS "code", too. Why would you not count HTML if it's in its own file, but assuming you would count it if it was JSX returned from a React component?

JSX isn't HTML, it's javascript functions, which are code. HTML, as the name suggest is a markup language, and CSS are style sheets. Neither of these are code.

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

#30
post #23

Earlier quoted context omitted.

You should check out Google's homepage sometime. One wouldn't expect that such a simple front would hide so many k of Javascript, but I guess it does a lot.

On my 2016 MBP Google keeps a constant 20% load on a single core. Sometimes it's even up to 60%. I really don't know what Google is doing there.

Mining bitcoins? :-D
Post reply on HN