Things Right". • Organizational tools. • When and where? • In all the situations where the human memory is fallible. • KISS - Keep It Simple, Stupid. • 6-7 items in a checklist. • Up to 10-12 when it becomes a habit.
Database indexing and optimization ◦ Memory management • less than 10–20% of the response time getting the HTML document from the web server to the browser. • Focus on the other 80–90% of the end user experience.
on the front-end. • Frontend improvements typically require less time and fewer resources ◦ Redesigning application architecture and code ◦ Finding and optimizing critical code paths ◦ Adding or modifying hardware ◦ Distributing databases • These takes week or even months.
made up of images. – HTTP Archive, 2016 • KeyCDN survey: 46% of the web performance experts said image optimization is the number one focus. • `compress-images`, `image-optimize-loader`, `imagemin`/`gulp-imagemin` • Google's WebP lossless images are 26% smaller than PNGs and 25-34% smaller than JPEG images.
scale them down. • "Optimization suggestion: By compressing and adjusting the size of the image you can save 8.3 KB (34%)." • This recommendation refers to the images being scaled down by the browser. • Upload images at scale • Upload multiple resolutions of your images • It is not always possible to avoid scaling with CSS • `srcset` and `sizes` attributes
page makes the slower it will load • To reduce HTTP requests: ◦ Inline your Javascript (only if it is very small) ◦ Using CSS Sprites (`background-position`) ◦ Reducing 3rd party plugins, libraries and frameworks that make a large number of external requests ◦ Combining your CSS and JS files (Not necessary when supporting HTTP/2) • Don’t generate requests for things aren’t in use • Don't load a js file that is not being used in the page in multipage web application/site
server close to user > improve response time of one HTTP request • Component web server close to the user > improve response time of many HTTP requests • CDN can dramatically decrease the website/application latency. • 50% of the 1-second page load time budget on mobile is taken up by network latency overhead. - WPT • The median desktop latency ranged from 65-145 milliseconds
Atwood • Benefits ◦ Multiplexing and concurrency ◦ Stream dependencies ◦ Header compression ◦ Server push ◦ No need for other HTTP/1.1 optimization practices: CSS sprints, resource in-lining and concatenation
`Expires` header to inform the client that the copy it holds of the component is valid until a specified time. • Example: `Expires: Wed, 28 Feb 2018 23:59:59 GMT` • `Expires` uses a specific date > stricter clock synchronization • Expiration dates have to be constantly checked • A new date must be provided in the server’s configuration • `Cache-Control` header uses `max-age` directive • Example: `Cache-Control: max-age=604800`
has primed cache (anasshekhamis.com) • Using a far future `Expires` header • What if those components changed? • Use "Revving Filenames" • Example: `img_2.1.png` or `img.png?v=2.1`
(RTT) • Redirect use ◦ Website redesign ◦ Tracking traffic flow ◦ Counting ad impressions ◦ Creating user friendly URLs • They delay the delivery of the HTML document. • Nothing can be rendered (User Experience)
Example: https://anasshekhamis.com/2018/01/01/docker-architecture-and-ecosystem > https://anasshekhamis.com/2018/01/01/docker-architecture-and-ecosystem/ • Use `Referer` logging to track inbound traffic patterns • Use `beacon` to track outbound traffic patterns • Pretty URLs should be part of the design (UX)
• On average sites, it would cost 10-15 MB of memory • CMS like Drupal (average sites) has a 60-100 MB of memory • Broken link checker ◦ http://www.brokenlinkcheck.com ◦ https://www.screamingfrog.co.uk/seo-spider/
main advantages ◦ They reassure the user that the system has not crashed but is working on his or her problem ◦ They indicate approximately how long the user can be expected to wait, thus allowing the user to do other activities during long waits ◦ Provide something for the user to look at, thus making the wait less painful • Putting stylesheets near the bottom of the document prohibits progressive rendering • Browsers block rendering to avoid redrawing elements if their styles change Render Blocking Resources
what is known by flash of unstyled content phenomenon Render Blocking Resources Place CSS at the top of the page, and use media queries to mark some CSS resources as non-render blocking.
the script blocks parallel downloading. • Reasons to that behaviour ◦ The script may use `document.write` to alter the page content. ◦ To guarantee that the scripts are executed in the proper order • With scripts, progressive rendering is blocked for all content below the script > Moving scripts lower in the page Render Blocking Resources
• Choose only the styles you need • Keep character sets down to a minimum • Host fonts locally or prefetch • Store in LocalStorage with Base64 Encoding • Consider CDN
the browsers that a given resource should be prefetched so it can be loaded more quickly. • Form: <link rel="dns-prefetch" href="//example-domain.com/"> • Gives a hint to the browser to perform a DNS lookup in the background to improve performance.
up early connections • Connections such as DNS Lookup, TCP Handshake, and TLS negotiation can be initiated beforehand • Form: <link href='https://anasshekhamis.com' rel='preconnect' crossorigin>
milliseconds for the browser to lookup the IP address for a given hostname • The response time depends on ◦ The DNS resolver (typically provided by the ISP) ◦ The load of requests on it ◦ Our proximity to it ◦ Our bandwidth speed • DNS lookups are cached on a special caching server maintained by the ISP
information remains in the operating system’s DNS cache • Reducing the number of unique hostnames reduces the number of DNS lookups • Google.com is an example with only one DNS lookup • However, reducing the number of unique hostnames has the potential to reduce the amount of parallel downloading • Avoiding DNS lookups cuts response times, but reducing parallel downloads may increase response times • Reduce DNS lookups by using Keep-Alive and fewer domains. Reduce DNS lookups