Accelerated Mobile Pages
Published: 2016-03-10 10:39:16

<p>Back in October, <a href="https://googleblog.blogspot.com/2015/10/introducing-accelerated-mobile-pages.html" target="_blank">Google introduced Accelerated Mobile Pages</a>. It is an open-source project that relies&nbsp;on its AMP HTML, a framework built on existing web technology designed to regulate and serve faster mobile web pages. The project is headed up by Google in collaboration with a few other big internet companies like Twitter, Linkedin and Wordpress, and is designed to be an open standard. The idea is that by introducing some basic constraints, Google and others can cache webpages and serve them instantly, in a similar but more open veign to Facebook&rsquo;s <a href="https://instantarticles.fb.com/" target="_blank">Instant Articles</a>, which will be available&nbsp;to all developers&nbsp;on April 12th at Facebook&rsquo;s F8 conference.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://i.imgur.com/NWXpBe3.png" alt="AMP Search results" width="480" height="297" /></p>
<p style="text-align: center;"><em>Google AMP&nbsp;search results</em></p>
<p>The cynical developer in your or I may look at this sort of thing as yet another standard we need to get caught up on with no guarantee that Google, or anyone else, will make long-term use of it. But Google has already gotten the&nbsp;major news publications on board and I have already seen it show up when I search news-related queries. Because there are certainly many&nbsp;technically unsavvy news organizations, this&nbsp;could be&nbsp;a nice opportunity for&nbsp;smaller shops to leapfrog them for more search exposure.</p>
<p>To use AMP, you need to create a second source of the content, similar to an RSS feed and reference it from within the main article.</p>
<pre class="language-markup"><code>&lt;link rel="amphtml" href="http://thepracticaldev.com/amp/accelerated-mobile-pages"&gt;
</code></pre>
<p><span style="font-family: Palatino, 'Palatino Linotype', 'Palatino LT STD', 'Book Antiqua', Georgia, serif; font-size: 21px; color: #1b1b1b; background-color: white;">The AMP page is basically a paired down version of the first one with some boilerplate like such:</span></p>
<pre class="language-markup"><code>&lt;!doctype html&gt;
&lt;html ⚡&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link rel="canonical" href="hello-world.html" &gt;
    &lt;meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"&gt;
    &lt;style amp-boilerplate&gt;body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}&lt;/style&gt;&lt;noscript&gt;&lt;style amp-boilerplate&gt;body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}&lt;/style&gt;&lt;/noscript&gt;
    &lt;script async src="https://cdn.ampproject.org/v0.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
 &lt;body&gt;
     Hello World!
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>Yes, there is an emoji in the code. If you don't like hipster programming, steer clear 😜.</p>
<p>Implementing Accelerated Mobile Pages&nbsp;is not a difficult task if you already had a straightforward design, have a good handle over your implementation and serve pages via the server&nbsp;and progressive enhancement. Since this is designed for content-based web pages nd not complex apps, I am hoping that is what you do. I am certain that a lot of news organizations do not have a well organized codebase, but AMP will reward those that do in the long run.</p>
<p>Since The Practical Developer makes great use of Twitter for content distribution via <a href="http://twitter.com/thepracticaldev" target="_blank">@ThePracticalDev</a>, I would be excited to see Twitter serve cached versions of AMP&nbsp;pages instantly, but it is unclear what Twitter&rsquo;s long term plans are. Their involvement to date has been in the form of providing support for tweets to be displayed swiftly via the AMP protocol.</p>