title: Journal-AMPed up
url: https://adactio.com/journal/9646
hash_url: 67543479546d48a5d3c8b730cbf6a934

<p>Apple has <a href="https://www.apple.com/news/">Apple News</a>. Facebook has <a href="https://instantarticles.fb.com/">Instant Articles</a>. Now Google has <a href="https://www.ampproject.org/"><dfn>AMP</dfn>: Accelerated Mobile Pages</a>.</p>

<p>The big players sure are going to a lot of effort to reinvent <a href="http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html">RSS</a>.</p>

<p>That may sound like a flippant remark, but it’s not too far from the truth. In the case of Apple News, <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/News_Publishing_Guide/SettingUpYourChannel.html#//apple_ref/doc/uid/TP40015407-CH8-SW1">its current incarnation</a> appears to be quite literally an RSS reader, at least until the unveiling of the forthcoming Apple News Format.</p>

<p>Google’s AMP project looks a little bit different to the offerings from Facebook and Apple. Rather than creating a proprietary format from scratch, it mandates a subset of HTML …with some proprietary elements thrown in (or, to use the more diplomatic parlance of the extensible web, <a href="http://w3c.github.io/webcomponents/spec/custom/">custom elements</a>).</p>

<p>The idea is that alongside the regular HTML version of your document, you provide a corresponding AMP HTML version. Because the AMP HTML version will be leaner and meaner, user agents can then grab the AMP HTML version and present that to the end user for a faster browsing experience.</p>

<p>So if an RSS feed is an alternate representation of a homepage or a listing of articles, then an AMP document is an alternate representation of a single article.</p>

<p>Now, my own personal take on providing alternate representations of documents is “Sure. Why not?” Here on <a href="https://adactio.com/">adactio.com</a> I provide RSS feeds. On <a href="https://thesession.org/api">The Session</a> I provide RSS, JSON, and XML. And on <a href="https://huffduffer.com/api">Huffduffer</a> I provide RSS, Atom, JSON, and XSPF, adding:</p>

<blockquote>
  <p>If you would like to see another format supported, share your idea.</p>
</blockquote>

<p>Also, each individual item on Huffduffer has a corresponding <a href="http://oembed.com/">oEmbed</a> version (and, in theory, an RDF version)—an alternate representation of that item …in principle, not that different from AMP. The big difference with AMP is that it’s using HTML (of sorts) for its format.</p>

<p>All of this sounds pretty reasonable: provide an alternate representation of your canonical HTML pages so that user-agents (Twitter, Google, browsers) can render a faster-loading version …much like an RSS reader.</p>

<p>So should you start providing AMP versions of your pages? My initial reaction is “Sure. Why not?”</p>

<p>The AMP Project website comes with a <a href="https://www.ampproject.org/faq/">list of frequently asked questions</a>, which of course, nobody has asked. My own list of invented frequently asked questions might look a little different.</p>

<h3>Will this kill advertising?</h3>

<p>We live in hope.</p>

<p>Alas, AMP pages will still be able to carry advertising, but in a restricted form. No more scripts that track your movement across the web …unless the script is from an authorised provider, like say, Google.</p>

<p>But it looks like the worst performance offenders won’t be able to get their grubby little scripts into AMP pages. This is a good thing.</p>

<h3>Won’t this kill journalism?</h3>

<p>Of all the horrid myths currently in circulation, the two that piss me off the most are:</p>

<ol>
<li>Journalism requires advertising to survive.</li>
<li>Advertising requires invasive JavaScript.</li>
</ol>

<p>Put the two together and you get the gist of most of the chicken-littling articles currently in circulation: “Journalism requires invasive JavaScript to survive.”</p>

<p>I could argue against the first claim, but let’s leave that for another day. Let’s suppose for now that, sure, journalism requires advertising to survive. Fine.</p>

<p>It’s that second point that is fundamentally wrong. The idea that the <em>current</em> state of advertising is the <em>only</em> way of advertising is incredibly short-sighted and misguided. Invasive JavaScript is not a requirement for showing me an ad. Setting a cookie is not a requirement for showing me an ad. Knowing where I live, who my friends are, what my income level is, and where I’ve been on the web …none of these are requirements for showing me an ad.</p>

<p>It is entirely possible to advertise to me <em>and</em> treat me with respect at the same time. <a href="http://decknetwork.net/">The Deck</a> already does this.</p>

<p>And you know what? Ad networks had their chance. They had their chance to treat us with respect with the <a href="https://en.wikipedia.org/wiki/Do_Not_Track">Do Not Track</a> initiative. We asked them to respect our wishes. They told us get screwed.</p>

<p>Now those same ad providers are crying because we’re installing ad blockers. They can get screwed.</p>

<p>Anyway.</p>

<p>It is entirely possible to advertise within AMP pages …just not using blocking JavaScript.</p>

<p>For a nicely nuanced take on what AMP could mean for journalism, see Joshua Benton’s article on Nieman Lab—<a href="http://www.niemanlab.org/2015/10/get-ampd-heres-what-publishers-need-to-know-about-googles-new-plan-to-speed-up-your-website/"><cite>Get AMP’d: Here’s what publishers need to know about Google’s new plan to speed up your website</cite></a>.</p>

<h3>Why not just make faster web pages?</h3>

<p>Excellent question!</p>

<p>For a site like adactio.com, the difference between the regular HTML version of an article and the corresponding AMP version of the same article is pretty small. It’s a shame that I can’t just say “Hey, the current version of the article <em>is</em> the AMP version”, but that would require that I only use a subset of HTML and that I add some required guff to my page (including an unnecessary JavaScript file).</p>

<p>But for most of the news sites out there, the difference between their regular HTML pages and the corresponding AMP versions will be pretty significant. That’s because the regular HTML versions are bloated with third-party scripts, oversized assets, and cruft around the actual content.</p>

<p>Now it is in theory possible for these news sites to get rid of all those things, and I sincerely hope that they will. But that’s a big political struggle. I am rooting for developers—like <a href="http://product.voxmedia.com/2015/5/6/8561867/declaring-performance-bankruptcy">the good folks at VOX</a>—who have to battle against bosses who honestly think that <a href="http://www.theverge.com/2015/9/17/9338963/welcome-to-hell-apple-vs-google-vs-facebook-and-the-slow-death-of-the-web">journalism requires invasive JavaScript</a>. Best of luck.</p>

<p>Along comes Google saying “If you want to play in our sandbox, you’re going to have to abide by our rules.” Those rules include performance best practices (for the most part—I take issue with some of the requirements, and I’ll go into that in more detail in a moment).</p>

<p>Now when the boss says “Slap a three megabyte JavaScript library on it so we can show a carousel”, the developers can only respond with “Google says No.”</p>

<p>When the boss says “Slap a ton of third-party trackers on it so we can monetise those eyeballs”, the developers can only respond with “Google says No.”</p>

<p>Google have used their influence like this before and it has brought them accusations of monopolistic abuse. Some people got very upset when they began labelling (and later ranking) mobile-friendly pages. Personally, I’ve got no issue with that.</p>

<p>In this particular case, Google aren’t mandating what you can and can’t do on your regular HTML pages; only what you can and can’t do on the corresponding AMP page.</p>

<p>Which brings up another question…</p>

<h3>Will the AMP web kill the open web?</h3>

<p>If we all start creating AMP versions of our pages, and those pages are faster than our regular HTML versions, won’t everyone just see the AMP versions without ever seeing the “full” versions?</p>

<p><a href="http://timkadlec.com/2015/10/amp-and-incentives/">Tim articulates a legitimate concern</a>:</p>

<blockquote>
  <p>This promise of improved distribution for pages using AMP HTML shifts the incentive. AMP isn’t encouraging better performance on the web; AMP is encouraging the use of their specific tool to build a version of a web page. It doesn’t feel like something helping the open web so much as it feels like something bringing a little bit of the walled garden mentality of native development onto the web.</p>

  <p>That troubles me. Using a very specific tool to build a tailored version of my page in order to “reach everyone” doesn’t fit any definition of the “open web” that I’ve ever heard.</p>
</blockquote>

<p>Fair point. But I also remember that a lot of people were upset by RSS. They didn’t like that users could go for months at a time without visiting the actual website, and yet they were reading every article. They were reading every article in non-browser user agents in a format that wasn’t HTML. On paper that sounds like the antithesis of the open web, but in practice there was always something very webby about RSS, and RSS feed readers—it put the power back in the hands of the end users.</p>

<p>Some people chose not to play ball. They only put snippets in their RSS feeds, not the full articles. Maybe some publishers will do the same with the AMP versions of their articles: “To read more, click here…”</p>

<p>But I remember what generally tended to happen to the publishers who refused to put the full content in their RSS feeds. We unsubscribed.</p>

<p>Still, I share the concern that any one company—whether it’s Facebook, Apple, or Google—should wield so much power over how we publish on the web. I don’t think you have to be a conspiracy theorist to view the AMP project as an attempt to <em>replace</em> the existing web with an alternate web, more tightly controlled by Google (albeit a faster, more performant, tightly-controlled web).</p>

<p>My hope is that the current will flow in both directions. As well as publishers creating AMP versions of their pages in order to appease Google, perhaps they will start to ask “Why can’t our regular pages be this fast?” By showing that there is life beyond big bloated invasive web pages, perhaps the AMP project will work as a demo of what the whole web could be.</p>

<p>I’ve been playing around with <a href="https://github.com/ampproject/amphtml">the AMP HTML spec</a>. <a href="http://www.kevinmarks.com/ampreaction.html">It has some issues</a>. The good news is that it’s open source and the project owners seem <a href="https://github.com/ampproject/amphtml/issues">receptive to feedback</a>.</p>

<h3>JavaScript</h3>

<p>No external JavaScript is allowed in an AMP HTML document. This covers third-party libraries, advertising and tracking scripts. This is A-okay with me.</p>

<p>The reasons given for this ban are related to performance and I agree with them completely. Big bloated JavaScript libraries are one of the biggest performance killers on the web. I’m happy to leave them at the door (although weirdly, web fonts—another big performance killer—are allowed in).</p>

<p>But then there’s a bit of an about-face. In order to have a valid AMP HTML page, you <em>must</em> include a piece of third-party JavaScript. In this case, the third party is Google and the JavaScript file is what handles the loading of assets.</p>

<p>This seems a bit strange to me; on the one hand claiming that third-party JavaScript is bad for performance and on the other, requiring some third-party JavaScript. <a href="https://responsivedesign.is/articles/whats-the-deal-with-accelerated-mobile-pages-amp">As Justin says</a>:</p>

<blockquote>
  <p>For me this is loading one thing too many… the AMP JS library. Surely the document itself is going to be faster than loading a library to try and make it load faster.</p>
</blockquote>

<p>On the plus side, this third-party JavaScript is loaded asynchronously. It seems to mostly be there to handle the rendering of embedded content: images, videos, audio, etc.</p>

<h3>Embedded content</h3>

<p>If you want audio, video, or images on your page, you must use <del>propriet…</del> <ins>custom</ins> elements like <code>amp-audio</code>, <code>amp-video</code>, and <code>amp-img</code>. In the case of images, I can see how this is a way of getting around the browser’s lookahead pre-parser (although responsive images also solve this problem). In the case of audio and video, the standard <code>audio</code> and <code>video</code> elements already come with a way of specifying preloading behaviour using the <code>preload</code> attribute. Very odd.</p>

<p><a href="https://responsivedesign.is/articles/whats-the-deal-with-accelerated-mobile-pages-amp">Justin again</a>:</p>

<blockquote>
  <p>I’m not sure if this is solving anything at the moment that we’re not already fixing with something like responsive images.</p>
</blockquote>

<p>To use <code>amp-img</code> for images within the flow of a document, you’ll need to specify the dimensions of the image. This makes sense from a rendering point of view—knowing the width and height ahead of time avoids repaints and reflows. Alas, in many of the cases here on adactio.com, I don’t know the dimensions of the images I’m including. So any of my AMP HTML pages that include images will be invalid.</p>

<p>Overall, the way that AMP HTML handles embedded content looks like a whole lot of wheel reinvention. I like the idea of providing custom elements as an <em>option</em> for authors. I hate the idea of making them a requirement.</p>

<h3>Metadata</h3>

<p>If you want to provide metadata about your document, AMP HTML currently requires the use of Google’s Schema.org vocabulary. This has a big whiff of vendor lock-in to it. <a href="https://github.com/ampproject/amphtml/issues/486">I’ve flagged this up as an issue</a> and <a href="https://github.com/ampproject/amphtml/pull/499">Aaron is pushing a change</a> so hopefully this will be resolved soon.</p>

<h3>Accessibility</h3>

<p>In its initial release, the AMP HTML spec came with some nasty surprises for accessibility. The biggest is probably the <em>requirement</em> to include this in your viewport <code>meta</code> element:</p>

<pre><code>maximum-scale=1,user-scalable=no
</code></pre>

<p>Yowzers! That’s some slap in the face to decent web developers everywhere. Fortunately <a href="https://github.com/ampproject/amphtml/issues/481">this has been flagged up</a> and I’m hoping it will be fixed soon.</p>

<p>If it doesn’t get fixed, it’s quite a non-starter. It beggars belief that Google would mandate to authors that they <em>must</em> make their pages inaccessible to pinch/zoom. I would hope that many developers would rebel against such a draconian injunction. If that happens, it’ll be interesting to see what becomes of those theoretically badly-formed AMP HTML documents. Technically, they will fail validation, but for very good reason. Will those accessible documents be rejected?</p>

<p><a href="https://github.com/ampproject/amphtml/issues/481">Please get involved on this issue</a> if this is important to you (hint: this should be important to you).</p>

<p>There are a few smaller issues. Initially the <code>:focus</code> pseudo-class was disallowed in author CSS, but <a href="https://github.com/ampproject/amphtml/issues/493">that’s being fixed</a>.</p>

<p>Currently AMP HTML documents <em>must</em> have this line:</p>

<pre><code>&lt;style&gt;body {opacity: 0}&lt;/style&gt;&lt;noscript&gt;&lt;style&gt;body {opacity: 1}&lt;/style&gt;&lt;/noscript&gt;
</code></pre>

<p><em>shudders</em></p>

<p>That’s a horrible conflation of JavaScript availability and CSS. <a href="https://github.com/ampproject/amphtml/issues/323">It’s being fixed</a> though, and soon all the opacity jiggery-pokery will only happen via JavaScript, which will be a big improvement: it should <em>either</em> all happen in CSS <em>or</em> all happen in JavaScript, but not the current mixture of the two.</p>

<h3>Discovery</h3>

<p>The AMP HTML version of your page is not the canonical version. You can specify where the <em>real</em> HTML version of your document is by using <code>rel="canonical"</code>. Great!</p>

<p>But how do you link from your canonical page out to the AMP HTML version? Currently you’re supposed to use <code>rel="amphtml"</code>. No, they haven’t checked <a href="http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions">the registry</a>. Again. I’ll go in and add it.</p>

<p>In the meantime, <a href="https://github.com/ampproject/amphtml/issues/498#issuecomment-146709054">I’m also requesting</a> that the <code>amphtml</code> value can be combined with the <code>alternate</code> value, seeing as <code>rel</code> values can be space separated:</p>

<pre><code>rel="alternate amphtml" type="text/html"
</code></pre>

<p>See? Not that different to RSS:</p>

<pre><code>rel="alterate" type="application/rss+xml"
</code></pre>

<h3>POSSE</h3>

<p>When I publish something on adactio.com in HTML, it already gets syndicated to different places. This is the Indie Web idea of <a href="https://indiewebcamp.com/POSSE">POSSE</a>: Publish (on your) Own Site, Syndicate Elsewhere. As well as providing RSS feeds, I’ve also got <a href="https://adactio.com/journal/7130">Twitter bots</a> that syndicate to Twitter. An <a href="https://ifttt.com/">If This, Then That</a> script pushes posts to Facebook. And if I publish <a href="https://adactio.com/notes/photos">a photo</a>, it goes <a href="http://flickr.com/photos/adactio">to Flickr</a>. Now that <a href="https://github.com/Medium/medium-api-docs">Medium is <em>finally</em> providing a publishing API</a>, I’ll probably start syndicating articles there as well. The more, the merrier.</p>

<p>From that perspective, providing AMP HTML pages feels like just one more syndication option. If it were the <em>only</em> option, and I felt compelled to provide AMP versions of my content, I’d be very concerned. But for now, I’ll give it a whirl and see how it goes.</p>

<p><a href="https://gist.github.com/adactio/73f404568bf5e0d000a6">Here’s a bit of PHP</a> I’m using to convert a regular piece of HTML into AMP HTML—it’s horrible code; it uses regular expressions on HTML which, as we all know, <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">will summon the Elder Gods</a>.</p>
