Show HN: Using Google AMP to build a Medium-style Jekyll site that loads in 65ms
github.com
github.com
1. A direct comparison to Facebook's react Github page may not be fair. Their page is 10 times heavier than the blog page - of course its going to be faster.
2. Actually the Facebook's React page is not that well designed when it comes to performance. I see a lot of scripts included in the FB react page blocking rendering (codemirror.js, etc) even in pages where they are not used. If those are removed, the time to first render should drop down by a lot.
3. I feel a more apt comparison would have be comparing to a purely static page like a blog hosted on Github. Not a page which actually includes a live code editor!
4. No one says the page loads in the DOMContentLoaded time. It is mostly a useless metric when it comes to performance measurement.
That's probably true of every slow site on the web. Part of the purpose of AMP is that it forces your site to be fast. Of course you can optimize a regular HTML page and make it faster, but you can't pass AMP validation with a slow site.
I updated my README file to compare page load speed with the Jekyll homepage too since it's a closer analog. But comparing to a random page that wasn't too optimized was sort of the point - most of the time, speed isn't the priority and that can make a big real-world difference for mobile users.
Isn't the point of AMP not to develop heavy sites for static content?
React is all the hype right now. And it is a nice system for creating dynamic single page apps. But there is little reason to use it for static websites, which could be cached easily, instead of rerendering the website on the client with Javascript. And instead of having automatically cached static website, we use local storage and such to get something resembling a cache.
I would love to see some mechanical sympathy in modern web development, instead of cargo culting all the new tech.
[1] http://facebook.github.io/react-native/
[2] https://github.com/facebook/react-native/blob/master/website...
The chain of build steps is quite complex though... but hey, if it works...
For example my blog: Most visitors read a single article and leave. Optimization: Serve page as one big blob if possible. Inline the CSS. Avoid images and widgets. Social buttons are implemented as CSS-styled links without Javascript-iframe-img stuff.
React is old school, the cool kids use VueJS nowadays.
I've never understood the use of AMP, just build your normal site properly in the first place and then you won't need it. It's almost like training-wheels for learning efficiency/optimization.
A major con against AMP in my opinion is that it is something else to learn on top of everything.
"Add this third tracking/analytics tool"; "Add this custom ad format here"; "Oh this partner will give us tons of money if we put this widget on the page"; "Oh let's use Brightcove video player"; "Oh let's auto-play videos"; "drive-by A/B testing"; "We don't control this third-party 2MB image", "The widget streams a 23MB .WAV file for background music that only auto-plays in mobile"; "Why build this in-house when we can just use this good third-party library?"; "Good third-party library costs too much, let's use this horrible but much cheaper one instead"; etc.
AMP allows you to tell your product manager: "Sorry! Not supported." Of course, with enough responses like this, a decision eventually comes down to not use AMP.
I like this reason. It's both a good reason for AMP to exist (albeit to solve a sad problem, with the product managers), as well as to justify not using it myself :-)
> Of course, with enough responses like this, a decision eventually comes down to not use AMP.
Perhaps. But having an external set of guidelines that relate to an all-or-nothing benefit (inclusion in Google's AMP program) seems helpful to me (from the eye of a developer who cares about bloat).
A small team of good developers could also formulate their own set of guidelines in order to avoid bloat and achieve fast loading. But those guidelines will have to be guarded by the developers against "political" forces, and there's a distinct possibility that more and more compromises will be made.
Exclusion from the AMP program provides a line in the sand, so to say.
If putting a brand on a set of techniques plus offering CDN space and serp priority gets publishers to actually build fast websites, then I am all in favor of it.
I've never understood why toddlers need training wheels on their bikes? Why don't they just bike properly in the first place?
I guess the only oversight I see in my original post is that most of the time, the webdevs aren't the ones with the final say anyway and maybe branding the restrictions will make it more palatable to publishers. It's just sad that we're at the point where it has to be done this way.
But it is telling that publishers are fine with being restricted by AMP, when they could have implemented those restrictions extremely easily on their own instead of having to be hand-held through the whole thing.
The other issue I have is that it's generally intended for mobile only. If the site was built for speed and efficiency from the ground up, it would be a fast experience everywhere
You say that like it's a bad thing! But that's the entire point. Without a clear set of rules, almost no one makes fast pages in real life.
This is especially true when you are working in a company where a wide mix of people have competing objectives. The developers want a fast page, the designers want a pretty page, the PMs want conversion, the business folks want lots of ads, etc. It makes it nearly impossible to build something fast without clear rules.
Take a random article on the TheVerge.com as an example. I'm sure they have fantastic web developers who want the site to load quickly and they definitely know how to build beautiful pages. But check out their normal responsive page you get if you visit their site directly on your phone:
http://www.theverge.com/2016/3/15/11233030/jj-abrams-moon-sh...
Using Chrome's "Regular 2G" throttling, that page takes 19.82s to hit DOMContentLoaded and an insane 1.3 minutes to hit Load. The total mobile page weighs 2.5mb!
Now check the AMP version of that same page. You can find it by looking for the 'link rel="amphtml"' tag in the header of the page:
http://www.theverge.com/platform/amp/2016/3/15/11233030/jj-a...
Using the same Chrome throttling settings, it hits DOMContentLoaded in 802ms and Load in 33.33s. And even then, almost all of that time is spent loading fonts and (in this particular article, very poorly optimized) images.
To a mobile user, that is a way better experience - the difference between bouncing and reading. And the only difference was having "a decided-upon set of restrictions".
If the site was built from the beginning with performance in mind, we'd all benefit, no matter what we're using to view the site.
I get that it has more to do with business side of things vs. the development side of things. Lots of hands in the pot at these companies and webdevs are only one part of it.
Of course this is in comparison with Medium blog posts which take 10's of seconds and scroll at 5 fps. Plain HTML with no CSS works for me, which is super fast if you get used to the plain style.
Are you connecting to the internet using a potato?
Here's Medium with a 10s load-time over a simulated cellular connection:
http://www.webpagetest.org/result/160315_FY_c1dc544bfe0add32...
5s over a simulated mediocre (i.e. Comcast median) cable connection:
http://www.webpagetest.org/result/160315_HH_a6ed41e9bd201183...
Is there a way to do it in a standardised way or should that even be desired? All browsers I've tried seem to render it fine and quickly (assuming js and the normal bells and whistles).
https://ageitgey.github.io/amplify/2016/03/08/example-post.h...
> AMP validation successful.
not sure what you mean
> AMP validation successful.
Maybe I'm missing something? I literally learned how to validate AMP pages from[1] 59 minutes ago :)
Looking at it now though
[console.warn]
https://www.ampproject.org/:22:42 The tag 'noscript > style : boilerplate - old variant' is deprecated - use 'noscript > style : boilerplate' instead. (see https://www.ampproject.org/docs/reference/spec.html#required-markup)
That 'warning' comes up as a whopping great big red error for my AMP pages that still have the old boilerplate. It seems AMP make an exception for their project site.That says a lot about HTML validation, then.
Thanks, WebKit (etc) authors! You worked hard so others don't have to.
The W3C HTML 4 spec didn't waste a word on parsing and simply referred to SGML [4], which (for very good reasons) no relevant browser actually implemented. Obviously, browser developers did some crazy/remarkable things before the WHATWG came along, but a lot of credit for today's lenient HTML parsing certainly belongs with the WHATWG.
[1] https://webkit.org/blog/1273/the-html5-parsing-algorithm/
[2] https://blogs.msdn.microsoft.com/ie/2011/07/06/html5-parsing...
[3] https://hacks.mozilla.org/2010/05/firefox-4-the-html5-parser...
Firstly, the claim that images must be supplied with a known height and width is wrong. All you need to provide to AMP is the aspect ratio of the image.
You can give the width as "16" and the height as "9" and AMP will calculate exactly what size to display the image. It would use any exact measurements provided only to determine the aspect ratio. That's why this layout can be called 'responsive' at all.
Example:
<amp-img width="4"
height="3"
layout="responsive"
src="/assets/images/your_picture.jpg">
</amp-img>
will validate and the image will be rendered at the largest size possible in 4:3 aspect ratio, relative to its flow context/container.In action:
https://wnda.github.io/amphtml-examples/layout/#development=...
https://wnda.github.io/amphtml-examples/basic-page/#developm...
---------------
Secondly, if you won't even know the aspect ratio of your images with any certainty, AMP doesn't give a damn about exact dimensions for background-images.
Proof:
http://wnda.github.io/amphtml-examples/experiments/backgroun...
With background-size: cover, background-images are actually extremely effective for responsive web design as long as you're not supplying massive images.
You might think it's a problem because the background-images will not be lazyloaded , but technically they sort of will be, because AMP intercepts everything in your page and serves it via HTTP/2 from its CDN. You just can't link the lazyload up with JavaScript callback.
What you can do is estimate the time it will take to download the image and configure a CSS animation to fire after a certain amount of time using the animation-delay CSS property.
Just an idea.
<link rel="amphtml" href="/yourampversionofpage" />
in the normal page.Those with JavaScript switched off probably won't be suggested the AMP pages in Google Mobile SERP.
So you could serve the JS-optional pages to all clients, progressively enhance for JavaScript users and offer AMP pages to mobile JavaScript users.
The crazy thing is that the demo-page actually loads quicker with NoScript on. Okay, so I didn't see the images (and because the text was Lorem Ipsum, I didn't realize they were missing), I'm on a high-bandwidth connection so unless the images are secretly huge, the images on their own shouldn't be too much of a factor to account for the difference.
So in other words, while AMP may be a useful line in the sand for responsive guidelines versus corporate politics / environment / product managers / etc, it's no replacement for just writing lean and efficient code in the first place (if at all possible).
edit: turns out the comparison wasn't entirely fair because obviously I didn't have Google's JS code cached. On the second load there's less of a difference.
* non AMP
* standard HTML5
* with pretty pic above fold
* not hosted on a Google CDN or any other CDN
is still faster than the AMP, Google CDN, no lovely pic above fold page.amp example page by the OP
https://cdn.ampproject.org/c/s/ageitgey.github.io/amplify/2016/03/08/example-post.html
https://www.webpagetest.org/result/160315_NN_CPY/
first byte 0.267s start render 0.916s speed index 928
a page of my small website http://www.veganblatt.com/veganer-ei-aufstrich
https://www.webpagetest.org/result/160315_NN_CPY/
first byte 0.176s start render 0.305s speed index 910only a slight difference. OP's site is just, well, very fast :)
You really don't need any AMP for this.
I guess it's a good thing that with a static HTML it's basically the same thing but without the fancyness and the Google cache in the background.
For companies, it's a framework that restricts the "bad" requirements that conflict with page loading performance.
You also don't bother loading what will never be seen, assuming the customer doesn't scroll down to the bottom of the site. This improves the customer's battery life because an HTTP request uses the radio which taxes the battery.
Further, by abiding by a set of standards, Google and others can trust the content will load quickly. That trust allows them to feature the content higher up in search results.
It's only a "standard" from the viewpoint of Google.
So it is a Google closed club? "you use our library, your site ranks up"? I doubt this is true. If it is, I doubt it will endure. If it endures, I doubt I wish to live in this world.
Yes, unfortunately that is exactly the case.
Try a Google search for any news-related topic on a mobile device (at least in the US) and you'll see that only Google AMP pages are featured in the top scrollable news widget:
That's why most of the major publishers are providing AMP versions of their content. You can find the linked AMP version of any news article by checking the HTML source and looking for the "amp" link tag in the header.
True it is not the same as the 65ms claimed in the article but its not that far off too.
The location of the test matters too. The time to first byte in your test is 82 ms - so there is no way DOM complete can happen in 65 ms in your case :) Probably try different locations for your test..
But even page load time and first render times aren't without their own problems. Resources loaded asynchronously also count towards the page load time - however, they are not necessarily detrimental to the user experience. Similarly, some pages flash a white screen before contents actually starts to appear. In these cases, the first render also becomes meaningless since the user doesn't care about the "paint" of a white screen.
Recently, other metrics such as the speed index and [RAIL](https://developers.google.com/web/tools/chrome-devtools/prof...) have come about. (Just the initial page load time does not matter for a good UX)
Mostly there is no one universal metric for all websites. Think about what your user wants to do on your site and optimise for that metric. For example, Twitter optimises for the time for the first tweet to appear on the timeline :)
Check also this amp hello world I did, if you want a bare AMP example https://github.com/fibo/hello-AMP
{% include analytics.html %}
https://github.com/fibo/hello-AMP/blob/master/gh-pages/_includes/analytics.html
<script type="text/javascript">...</script>
You're kidding, right? You need to implement analytics using the AMP Analytics Custom Element or it'll just fail validation.Funny how much trash people are talking.
Keep the internet fast.
Grav CMS is an open-source CMS. Therefore, it is a better option than Jekyll when you need to create a client website.
It is also used as an alternative to Medium.com for creating a personal blog.
I hope you guys enjoy it :)