Skip to main content

Kevin Marks

Day 7: To AMP or not to AMP? #100DaysOfIndieWeb

1 min read

Alan made a bookmarklet to go from the AMP version of an article to the canonical one. This is useful for sharing, but as Aaron pointed out, going the other way is handy for removing ad cruft, which can be a 14GB/day download.

So, here's the 'to amp' version:

javascript:var url = false;var links = document.getElementsByTagName('link');Object.keys(links).forEach(function(key){if(links[key].rel !== 'amphtml'){return;};url = links[key].href;});if(!url){ alert('No AMP URL'); };if(url){document.location = url;};

I'd suggest installing both, so you can toggle back and forth. A related one just turns the url bar into the canonical version for copying (this is handy for removing the utm_ cruft that may be there):

javascript:var c = document.querySelector("link[rel=canonical]"); if(c){ history.replaceState({},document.title, c.href); }

Using bookmarklets on mobile browsers is a bit annoying; but as Chrome syncs them across devices, you can type the name you give the bookmarklet in the address bar and then click it:

using a bookmarklet on mobile chrome