The Web Performance Collection
Copyright 2017 SitePoint Pty. Ltd.
Ebook ISBN: 978-1-925836-14-1
- Cover Design: Alex Walker
Notice of Rights
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews.
Notice of Liability
The author and publisher have made every effort to ensure the accuracy of the information herein. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any damages to be caused either directly or indirectly by the instructions contained in this book, or by the software or hardware products described herein.
Trademark Notice
Rather than indicating every occurrence of a trademarked name as such, this book uses the names only in an editorial fashion and to the benefit of the trademark owner with no intention of infringement of the trademark.
Published by SitePoint Pty. Ltd.
48 Cambridge Street Collingwood
VIC Australia 3066
Web: www.sitepoint.com
Email: books@sitepoint.com
About SitePoint
SitePoint specializes in publishing fun, practical, and easy-to-understand content for web professionals. Visit http://www.sitepoint.com/ to access our blogs, books, newsletters, articles, and community forums. Youll find a stack of information on JavaScript, PHP, design, and more.
Preface
Performance simply matters. Technology may allow us to go bigger, but maybe not necessarily be better when it comes to performance. Now is the time to utilize the amazing tools that are available to us for making websites and applications faster, and to learn how to improve user experience and satisfaction.
This collection contains four books:
- Front-end Performance is a collection of practical articles on front-end website performance for front-end developers. It's packed with useful, real world hints and tips that you can use on your sites today.
- Back-end Performance is a collection of articles on back-end website performance for web developers. It outlines useful strategies and practical advice.
- Performance Tools contains tutorials on some of the most popular and powerful website performance tools available.
- Performance Project contains a series of practical, real-world tutorials, all based around a single project: a simple image gallery blog. We'll build the project, and then run through a series of performance optimization processes; by the time we're done, we'll have achieved very significant performance improvements.
Who Should Read This Book?
This collection is for developers who wish to build sites and apps that run faster. Youll need to be familiar with HTML and CSS and have a reasonable level of understanding of JavaScript in order to follow the discussion, and for book 2, Back-end Performance, you'll need some understanding of server-side development.
Conventions Used
Code Samples
Code in this book is displayed using a fixed-width font, like so:
A Perfect Summer's Day
It was a lovely day for a walk in the park.The birds were singing and the kids were all back at school.
Where existing code is required for context, rather than repeat all of it, will be displayed:
function animate() { new_variable = "Hello";}
Some lines of code should be entered on one line, but weve had to wrap them because of page constraints. An indicates a line break that exists for formatting purposes only, and should be ignored:
URL.open("http://www.sitepoint.com/responsive-web-design-real-user-testing/?responsive1");
Youll notice that weve used certain layout styles throughout this book to signify different types of information. Look out for the following items.
Tips, Notes, and Warnings
Hey, You!
Tips provide helpful little pointers.
Ahem, Excuse Me ...
Notes are useful asides that are relatedbut not criticalto the topic at hand. Think of them as extra tidbits of information.
Make Sure You Always ...
... pay attention to these important points.
Watch Out!
Warnings highlight any gotchas that are likely to trip you up along the way.
Chapter 1: Which Browsers Should Your Website Support?
by Craig Buckler
The question "which browsers should my website/app support?" isoften raised by clients and developers. The simple answer is a list ofthe top N mainstream applications. But has that policy becomeirrelevant?
What are the Most-used Browsers?
The top ten desktop browsers according toStatCounter for May 2017 were:
- Chrome 59.37% market share
- Firefox 12.76%
- Safari 10.55%
- IE 8.32%
- Edge 3.42%
- Opera 1.99%
- Android (tablet) 1.24%
- Yandex Browser 0.48%
- UC Browser 0.41%
- Coc Coc 0.33%
Mobile now accounts for 54.25% of all webuseso we also need to examine the top ten phone browsers:
- Chrome 49.23%
- Safari 17.73%
- UC Browser 15.89%
- Samsung Internet 6.58%
- Opera 5.03%
- Android 3.75%
- IEMobile 0.68%
- BlackBerry 0.26%
- Edge 0.15%
- Nokia 0.12%
The worldwide statistics don't tell the whole story:
- Patterns vary significantly across regions. For example, Yandex isthe second most-used Russian browser (12.7% share). Sogou is thethird most-used browser in China (6.5%). Opera Mobile/Mini has a 28%share in Africa.
- New browser releases appear regularly. Chrome, Firefox and Operareceive updates every six weeks; it would be impractical to checkversions going back more than a few months.
- The same browsers can work differently across devices and operatingsystems. Chrome is available for various editions of Windows, macOS,Linux, Android, iOS and ChromeOS, but it's not the same applicationeverywhere.
- There is an exceedingly long tail of old and new, weird andwonderful browsers on a range of devices including games consoles,ebook readers and smart TVs.
- Your site's analytics will never match global statistics.
Are Browsers So Different?
Despite the organic variety of applications, all browsers have the samegoal: to render web pages. They achieve this with a rendering engineand there is some cross-pollination:
- Webkit is used in Safari on macOS and iOS.
- Blink is a fork of Webkit now used in Chrome, Opera, Vivaldi andBrave.
- Gecko is used in Firefox.
- Trident is used in Internet Explorer.
- EdgeHTML is an update of Trident used in Edge.
The majority of browsers use one of these engines. They're differentprojects with diverse teams but the companies (mostly) collaborate viathe W3C to ensure new technologies are adopted by everyone in the sameway. Browsers are closer than they've ever been, and modern smartphoneapplications are a match for their desktop counterparts. However, no twobrowsers render in quite the same way. The majority of differences aresubtle, but they become more pronounced as you move toward cutting-edgetechnologies. A particular feature may be fully implemented in onebrowser, partially implemented in another, and non-existent elsewhere.