2

enter image description here

While testing my site on Google PageSpeed insights tools it showing very much poor result of Mobile Page Load speed as you see on the image. How can i get a well score.is it will be solved if solve the three category of optimization suggestions. Among the three categories Where, in the Leverage Browser Caching section showing enter image description here

How can i solve the problem about https://connect.facebook.net/en_US/fbevents.js (20 minutes) this line. Any suggestion please?

1 Answer 1

3

Unfortunately you can't directly remove the Insights warning. The PageSpeed tool can't tell that you don't own the facebook.net domain and therefore have no control over the response headers.

Presumably Facebook have given this file a short(ish) cache expiry time so they can deploy changes to it and have them take effect pretty quickly.

I say you can't "directly" remove the warning because there is a fudgey workaround that's been posted on Stack Overflow. It's not a very nice workaround though and a lot of people (myself included) would say it's massive overkill and creates more problems than it solves.

1 - Fudge it

You could create a job somewhere that copies the Facebook script to your server or a suitable CDN on a regular basis - maybe every 20 minutes as that's the current header expiry that Facebook is using. When you serve it you could increase the cache expiry time in the header to whatever you want. This would remove the warning from the PageSpeed report.

However, I think this is a really bad idea for a couple of reasons...

  • If Facebook release a breaking change to the script you'll have old versions of it sitting in browser caches for a long time - longer than Facebook intended.
  • You'd be introducing a number of things that could go wrong. Your job could fail, it could create a blank file, or no file at all! It might not run for several days and miss vital updates to the script.

I call this option a fudge because it is. It's not actually fixing a problem, because in this instance there isn't really a problem to fix.

2 - Remove it

Do you need to load the Facebook script? Can it just be removed?

If you need to load it to deliver a particular UX you should just expect it to affect your performance score and move on.

3 - Ignore it (Recommended)

PageSpeed is a useful tool and can raise some important performance issues when it comes to maximizing the efficiency of your website, but you should use PageSpeed and other similar tools only as a guide.

Sometimes resolving all of the "problems" these tools raise will just make more problems elsewhere. Fix the important stuff that you have control over.

More reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.