4

I am implemented AMP pages. So I am calling https://cdn.ampproject.org/v0.js api from cdn. But I want to save this file in my project. Because third party API making slow website. I have tested my website in googlepagespeed

1: https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.winni.in%2Fcake-delivery-in-bangalore, Then my website slow in mobile Like 84 page speed score. But before AMP my pagespeed score in mobile was 91. That's why I want to host this file in my project.


enter image description here

I am Using:

<script src="https://cdn.ampproject.org/v0.js" async></script>

Can we host locally or not? After host locally it will reflect by google or not? Your suggestion will very helpfull for me.

Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
Varun Sharma
  • 4,632
  • 13
  • 49
  • 103
  • Is your script tag for `v0.js` set to async? It won't be render blocking if you have that... – Luke Feb 20 '17 at 13:08
  • 1
    @Luke. I am using . – Varun Sharma Feb 20 '17 at 13:10
  • Hmm I wonder why it says that it's render blocking in the report? Maybe the script tags need moving to the bottom of the page if it isn't already? – Luke Feb 20 '17 at 14:24
  • @Luke, it doesn’t. It says that `https://www.winni.in/…/main.min.css` is render-blocking and suggests you to make use of browser cache in case of `v0.js`. I think that you shouldn’t host `v0.js` on your own, as it’s fresh and evolving specification (maybe that’s why it gets cached for only 50 minutes). What you _can_ do is to load CSS asynchronously (and put it into `noscript` just in case). – gsc Feb 20 '17 at 14:56
  • See: http://stackoverflow.com/a/41854836/5976917 and http://stackoverflow.com/a/41965299/5976917 . So don't do it ;-) And https://www.winni.in/cake-delivery-in-bangalore is not a valid AMP Site. – Lovntola Feb 20 '17 at 19:35
  • You can't load css async. Its need for rendering. Best solution: remove all css that you don't need and put the css file inline in your html. – Lovntola Feb 20 '17 at 19:38
  • @Luke. thanks. Actually when i am using noscript for loading css file, Then it is not compatible with all mobile browser. And if I use inline css then html page will break because my css is so lengthy. – Varun Sharma Feb 21 '17 at 04:36
  • @Luke. If I am not using inline css then It is not valid amp page? – Varun Sharma Feb 21 '17 at 04:40

1 Answers1

3

You can do it but I'd strongly discourage self-hosting the AMP runtime library (v0.js).

It'll cause your page to fail the AMP Validator (which means it won't be served from Google cache with the ⚡ icon on Google search) and miss the bug fixes and new features pushed in our weekly updates.

choumx
  • 151
  • 2
  • Agreed with this. I would also add that the version of the URL at https://cdn.ampproject.org/v0.js is more likely to be in your user's cache than your own site's version. As a result, it is very reasonable to believe that it may actually load *faster*. – Gregable Mar 23 '17 at 23:27