Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable compression on facebook sdk served files to optimize site

Tags:

I was running page speed insights on my website and was given the following result:

Compressing resources with gzip or deflate can reduce the number of bytes sent over the network.

Enable compression for the following resources to reduce their transfer size by 350.1KiB (71% reduction).

Compressing https://static.xx.fbcdn.net/rsrc.php/v2/yV/r/jchZvGuNSq4.js could save 230.8KiB (72% reduction).

Compressing http://connect.facebook.net/en_US/sdk.js could save 119.3KiB (69% reduction).

I am wondering if anyone knows how to compress these files since they are served out directly from the facebook sdk?

This is the facebook script I am using in my webpages:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '---- my app ID here -----',
      xfbml      : true,
      version    : 'v2.4'
    });
  };
(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

Any help would be greatly appreciated as I have been unable to find a clear answer to this identified problem.

like image 233
Austin Avatar asked Dec 16 '15 00:12

Austin


People also ask

How do I enable gzip compression for my website?

Gzip on Windows Servers (IIS Manager)Open up IIS Manager. Click on the site you want to enable compression for. Click on Compression (under IIS) Now Enable static compression and you are done!

How do I enable text compression in WordPress?

Upon activation, go to the Settings » WP Super Cache page » Advanced in your WordPress dashboard. Then, simply check the box 'Compress pages so they're served more quickly to visitors' box. You then need to scroll down the page and click the 'Update Status' button to save your changes.

What is the work of gzip compression?

Gzip, the most popular compression method, is used by web servers and browsers to seamlessly compress and decompress content as it's transmitted over the Internet. Used mostly on code and text files, gzip can reduce the size of JavaScript, CSS, and HTML files by up to 90%.


Video Answer


2 Answers

You can't. It's served from a third party which is Facebook. We should reach them out and ask them to compress these files.

Edit:

Facebook actually lent us an ear, and compressed some of their SDKs which is great

like image 190
Aysennoussi Avatar answered Oct 12 '22 01:10

Aysennoussi


I have also noticed this and went Googling and found your SO question. I did some checks and it looks like they already compress their static files. Have a look at this:

http://www.whatsmyip.org/http-compression-test/

EDIT: I recommend using https://checkgzipcompression.com/ now, the previously named test seems to have lost its functionality

I'm not sure why Pagespeed Insights doesn't pick up on this, but I am pretty sure you can ignore this. Because you don't have much influence on the way they serve their static files and I would be suprised if they didn't compress their static files at a company like Facebook.

like image 39
Ogier Schelvis Avatar answered Oct 12 '22 00:10

Ogier Schelvis