The Need for Speed! Accelerated mobile, beyond AMP

87
@jonoalderson

Transcript of The Need for Speed! Accelerated mobile, beyond AMP

Page 3: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

There’s a lot of much-needed focus on (mobile)

performance at the moment

@jonoalderson

Page 5: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

On AMP, briefly...

Page 6: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson6

Just the tip of the iceberg...

@jonoalderson

Page 7: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

http://bit.ly/badams-amp

Page 8: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Risky? Dangerous? Subversive, even?

@jonoalderson

Page 9: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Are you actively managing your AMP cache?

https://developers.google.com/amp/cache/update-ping

Page 10: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 11: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

You don’t need AMP.

You can do this yourself.

Page 12: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Anyone can (theoretically) create an AMP cache.

https://github.com/ampproject/amphtml/blob/master/spec/amp-cache-guidelines.md

@jonoalderson

Page 13: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 14: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

http://bit.ly/ampJSWhat if you could

de-couple AMP?

Page 15: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

To clarify, I’m not saying that you shouldn’t adopt AMP.

Page 16: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

So, what’s the broader performance toolkit look like?

Page 17: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Infrastructure & network optimisation

Page 18: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

HTTP2 Implications

@jonoalderson

Page 19: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

HTTPS isn’t a binary thing!

Page 20: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

SSL Chain LengthOn certificate length...

Page 21: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

HSTS● Become compliant by adding extra HTTPS checks

● Register for the HSTS preload list (hstspreload.org)

● Skip the HTTP/HTTPS redirect when people type example.com

Page 22: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

online.marketing/guide/https

More here...

Page 23: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Let’s go faster.

Page 26: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

We need to go smarter, not faster

Page 29: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Connection & data transfer

Page 30: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

With HTTP2, you don’t need to worry as much about round trips...

...but you should still consider what you’re transferring,

and how.

@jonoalderson

Page 31: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

For devices...● Detect early, and adapt. Responsive = expensive!

● Make CSS mobile-first (build up from min-width); typically reduces sizes.

○ Conditionally layer on / load more for larger devices.

3131

@jonoalderson

Page 32: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

For media/images…Test CSS3 vs images vs sprites vs encoding vs inlining

Page 33: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

http://bit.ly/srcsetstuff

SRCSET is the only solution for managing image sizes/resolutions.

Page 34: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

...And you can also use <picture> to support multiple formats

Page 35: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

base64-image.de

You can also base64() encode images...

Page 37: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Sprite sheets are might still be a thing!

Page 38: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

https://developers.google.com/speed/webp/

WebP > JPG & PNG

Page 39: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Error management for common request headaches

Manage your robots, favicons, and other irritations.

@jonoalderson

Page 40: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

apple-touch-icon.png (and variants)

favicon.ico (and variants)

browserconfig.xml

Feeds (/rss/, /feed/, etc)

Invalid page/date ranges

Broken internal links (and missing http links)

Alternate sitemap and metadata urls

Breaking parameters (especially on images, from search engines)

Page 41: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Measurement

Page 42: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Which metrics matter?● There’s no such thing as ‘speed’. What are we measuring?

● Numbers from Google Pagespeed Insights, Pingdom,

WebPageTest, GA, etc, are all nonsense

● User satisfaction metrics > any technical speed metrics

@jonoalderson

Page 43: The Need for Speed! Accelerated mobile, beyond AMP

developers.google.com/speed/pagespeed/insights/

@jonoalderson

Page 44: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

The Waterfall in Chrome

@jonoalderson

Page 45: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

http://bit.ly/newchrometoys

Brand New Chrome Dev Toys!

Page 46: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Which metrics matter?● Don’t ignore, or get fixated on time ‘til first byte.

● You need to fix the front end and the back end.

@jonoalderson

Page 47: The Need for Speed! Accelerated mobile, beyond AMP

webpagetest.org

@jonoalderson

Page 48: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Other Tools

Page 49: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 50: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 51: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 52: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 53: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Undoing bad habits

Page 54: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Hostname sharding

https://blog.stackpath.com/glossary/domain-sharding/

Page 55: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Resource combination

Page 56: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

(I’m not going to talk about)

Back-end optimisation

Page 57: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Options for handling angular/react sites...1. Hope for the best

2. Serve static HTML versions, then let the framework pick up

the heavy lifting (using something like or PhantomJS)

3. Use something like Prerender.io (paid, or self-hosted).

Page 58: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

● There comes a point where you outgrow a single server.

● If you’ve finite RAM and CPU, consider separating servers and

databases. Latency, however!

● Consider caching, varnish, load-balancers

Server Ecosystems

Page 59: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Server Ecosystems

Varnish (static page cache) < Apache/Nginx < PHP/Python

(memcache) < MySQL/NoSQL (request cache)

vs

Page 60: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

SCARY?Learn by doing

Page 61: The Need for Speed! Accelerated mobile, beyond AMP

DIY time

@jonoalderson

Page 62: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 63: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 64: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 65: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 66: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

(I’m going to skim over)

Front-end optimisation

Page 67: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Caching Policies● Set your expiry times (appropriately!)

● Use 304 “Not Modified” header

● Use ETags

Page 68: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Resource Hints● Preload, preconnect, prefetch, dns-prefetch, prerender, and subresource.

○ <link rel="dns-prefetch" href="//example.com">

○ <link rel="prefetch" href="image.png"> (when idle)

○ <link rel="subresource" href="styles.css"> (prioritises)

○ <link rel="preload" href="/styles/other.css" as="style"> (prioritises)

● Pass as tags, headers, or via js

● NB: Rel next/previous automatically triggers prefetch in Chrome+Firefox

Page 69: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

CDNs are still important● Localisation is important!

● Latency is a bottleneck more often than you’d think.

● Cookieless subdomains reduce header sizes!

● Use resource CDNs (eg., cdnjs.cloudflare.com) for things like jQuery.

● Your first line of defense.

Page 70: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 71: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Above the fold (critical path) rendering

● Reduces waiting time for the

browser to download assets

● ...but can’t be (easily) cached!

● loadCSS is your friend (async loading and js support)https://github.com/filamentgroup/loadCSS

● Takes advantage of rel preload

http://bit.ly/criticalpathcss

Page 72: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

(Re)paint & (Re)flow● Consider how the page is constructed

and how it behaves

● Minimise unknowns to reduce tearing

and reflow in particular

● Small technical gains, big perception

gains

https://developers.google.com/speed/articles/reflow

Page 73: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

CSS specificity = slow paint● .container > nav > ul > li > a { color: red; }

● .main-nav-link { color: red; }

Page 74: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Animation & FPS● jQuery, scrolling and changing elements costs GPU and CPU

● Consider the user’s physical hardware

● To maintain 60fps, you frame animations need to execute in less than 14ms.

● Transformation and opacity are the only ‘free’ animations.

● Measure with Chrome, and kick your devs!

Page 75: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Deferring / async resources● Do you need to load everything immediately?

● Do you need to load everything in the <head>?

● Do you need to load everything on every page?

● Do you understand the dependencies?

● What can you defer, load asynchronously, or load conditionally?

Page 76: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

(You should go learn about)

PWAs

Page 77: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

https://developers.google.com/web/progressive-web-apps/

Page 78: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

“Twitter Lite and High Performance React Progressive Web Apps at Scale”

http://bit.ly/twitterpwa

Page 79: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 80: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Key takeaways...

Page 81: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Page 82: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

You have a million opportunities to improve

performance ...and every byte matters to users.

Page 83: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Ignore all of the scores the tools give you, and

just make things faster.

Page 84: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

Don’t neglect your infrastructure and back-

end opportunities

Page 85: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

The landscape is changingDon’t get caught up in today’s hype

Page 86: The Need for Speed! Accelerated mobile, beyond AMP

@jonoalderson

AMP is not the end.(but this is)

Page 87: The Need for Speed! Accelerated mobile, beyond AMP

GO OUT AND WIN