Going Google AMP

Faster, Google! Faster!

If you’re reading this on a phone, and you got here via a Google search, you might have noticed that my site loaded rather quickly. Indeed, thanks to Google AMP (accelerated mobile pages), the entire page was pre-rendered by your mobile device before you even tapped the link. So cool, right!? On top of providing visitors with a quicker experience, valid AMP pages also require site owners to forego much of the cruft typically found on websites these days, resulting in a much more pleasurable reading experience.

Converting my site, as simple as it is, to be totally valid AMP wasn’t as easy as I expected it to be, however.

Because of the ban on custom javascript, for example, posts that include Github code snippets, fail validation. Eventually, I plan to come up with a better solution for embedding code snippets, but it seamed relativly low value, given the amount of work.

The other pain was forms. AMP only allows forms using the AMP-FORM extension. Specifically, it means forms must be submitted using no additional javascript, and the response must include a number of specific headers. That meant having to come up with alternative solutions for my contact form, and the Mailchimp signup form on the footer of every post. Signing up for the mailing list still causes an error, but due to a lack of support from Mailchimp, I decided to use the error message section to show a success message.

For the contact form, I decided to build a proper backend using AWS Lambda. This was also surprising more complex than I initially expected it to be, mainly due to the inability to change the “Content-Type” header to something other than “multipart/form-data”. The AWS API Gateway doesn’t really support this particular content-type, so I ended up extracting and parsing the raw multipart request body to get the form field values. Ick.

Overall, I think AMP is a net-positive for the web. I’m looking forward to see how the project evolves, though I wouldn’t want to be the one on the hook for having to make a larger site pass AMP validation.