WHAT'S DISCUSSED IN THERE? Stop dummy history fast-forwarding Ignore clicks on iframes that have moved in the last 200ms Defer image loading until they are viewable Defer iframe loading until they are viewable Lower loading priority of cross-origin iframe
“For many, reading on the mobile web is a slow, clunky and frustrating experience - but it doesn’t have to be that way.” Accelerated Mobile Pages Project
GETTING STARTED AMP file HTML TAGS CAN BE USED UNCHANGED IN AMP HTML EXCEPT IMG, SCRIPT, VIDEO, IFRAME, ... https://www.ampproject.org/docs/reference/spec
CUSTOM MARKUP IF YOU NEED MORE ELEMENTS custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"> custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js">
"new" approach if (this.canUseNativeApis_()) { // Check if font already exists. if (this.document_.fonts.check(fontString)) { resolve(); } else { // Load font with native api if supported. this.document_.fonts.load(fontString).then(() => { // Workaround for chrome bug // https://bugs.chromium.org/p/chromium/issues/detail?id=347460 return this.document_.fonts.load(fontString); }).then(() => { if (this.document_.fonts.check(fontString)) { resolve(); } else { reject(new Error('Font could not be loaded,' + ' probably due to incorrect @font-face.')); } }).catch(reject); } } https://github.com/ampproject/amphtml/blob/master/extensions/amp-font/0.1/fontloader.js#L112-L131 CUSTOM FONTS
"new" approach if (this.canUseNativeApis_()) { // Check if font already exists. if (this.document_.fonts.check(fontString)) { resolve(); } else { // Load font with native api if supported. this.document_.fonts.load(fontString).then(() => { // Workaround for chrome bug // https://bugs.chromium.org/p/chromium/issues/detail?id=347460 return this.document_.fonts.load(fontString); }).then(() => { if (this.document_.fonts.check(fontString)) { resolve(); } else { reject(new Error('Font could not be loaded,' + ' probably due to incorrect @font-face.')); } }).catch(reject); } } https://github.com/ampproject/amphtml/blob/master/extensions/amp-font/0.1/fontloader.js#L112-L131 CUSTOM FONTS
FONT LOADING STRATEGY Rethink the usage of fonts! 01 Avoid FOIT! 02 03 Go for FOUT and adjust fallback fonts! https://www.zachleat.com/web/comprehensive-webfonts/
ANIMATIONS Use transform and opacity 01 Promote moving elements with 'will-change' 02 03 Don't overdo it https://developers.google.com/web/fundamentals/.../stick-to-compositor-only-properties-and-manage-layer-count https://csstriggers.com/
“I’ve been on the jQuery team for many years, and personally have seen how a library can drive meaningful, healthy change to the ecosystem at large. This is what we want.” Paul Bakaus Open Web Developer Advocate at Google https://medium.com/@pbakaus/doesnt-come-across-snarky-all-good-9d4269f7dbe6
AMP CACHE & SEARCH How can it be so fast? class="u2quVpIWVr0__amp-doc" allowfullscreen="true" scrolling="no" src="https://cdn.ampproject.org/v/www.bbc.co.uk/news/amp/ 36202424? amp_js_v=5#dialog=0&prerenderSize=1&visibilityState=hid den&paddingTop=54&history=1&p2r=0&horizonta lScrolling=0&csi=0&storage=1" style="height: 568px;"> SMART PRELOADING https://www.google.nl/amp/www.bbc.co.uk/...
“If you try to convince somebody, that contents are worth their time, you don't want a loading bar to get in their way.” Anand Varma National Geographic