The top web performance killers and how to prevent them
Posted Feb 19, 2020 | 9 min. (1824 words)Loading speeds of websites will always be a tricky thing to manage. They depend on anything and everything between your user’s choice of device and the server hardware your site runs on.
There are many web performance killers that can be removed as you develop your web page. Removing as many of these barriers as possible is critical if you want your website to load smoothly and quickly for the majority of your users. Here are some suggestions for streamlining everything that is within your control to allow for the fastest possible load times for your users.
Get visibility into the performance of your app, including load time distribution, with Raygun Real User Monitoring.
Get unlimited monitoring for 14 days with a free trial of Raygun’s Real User Monitoring software
1. Uncompressed static assets on the server
When a user hits your website, a call is made to your server to deliver the requested files. The bigger these files are, the longer it takes for them to get to your browser and appear on the screen. This is one of the biggest web performance killers.
Gzip is a utility that will reduce your file transfer speed from your server to the browser by compressing your web pages and stylesheets before sending them over to the browser. Compression drastically reduces transfer time since the resulting files are much smaller (this can result in up to 70% file size reduction).
Regarding cost versus benefit, the use of Gzip compression should be near the top of your page speed optimizations if you don’t have it set up already.
2. Unminified CSS and JavaScript
Minification will reduce the size of a CSS or JavaScript file and remove all unnecessary characters from code while maintaining its functionality.
Minifying CSS and JavaScript:
- Removes whitespace, comments, and unused code
- Optimizes conditional expressions
- Shortens variable and function names
- Obfuscates production code
Minification also reduces network latency (the time it takes for data packets to get from one point to another), leading to faster browser load times.
To minify stylesheets, try CSSNano and csso. CSSNano can be integrated into your workflow as a plugin for postcss.
To minify JavaScript, try UglifyJS2. You can also utilize UglifyJS in your workflow through the Grunt plugin, or Gulp plugins like gulp-uglify or gulp-source maps.
3. Non-optimized images
Images on a page can be optimized to reduce their file size without impacting the quality. We do a deep dive into this here.
A large number of websites use images, and images usually account for most of the downloaded data on a page. Optimizing images is one of the easiest ways to increase page performance.
- Lossless compression
- Convert images into web-appropriate file types
- Remove some of the image data without compromising the quality
- Reduce the white space around images
- Save images in appropriate dimensions
Learn more about optimizing images for the web
4. Not leveraging browser caching
Caching reduces the load time of web pages for repeat visitors by storing files on a user’s browser. Stored files do not need to be fetched or loaded again for a specified period. When users first visit a site, resources are fetched over the network and may require multiple trips between the client and server. Caching stores commonly used files and thus removes the need to fetch that content again in the near future, making subsequent site visits faster.
To enable browser caching, add the Cache-Control and ETag (entity tag) headers to HTTP response headers.
- Cache-Control defines how, and the period, a response can be cached by the browser and other caches.
- ETag provides a validation token that is used to communicate with the server to check if a resource needs to be updated.
Learn more about leveraging browser caching
5. Too many redirects
Redirects are often set up if a website or specific web page moves, if the page is renamed, or the page’s URL is being optimized for SEO. However, over time, the need for redirects can build up so that a user may actually be redirected several times before they arrive at the actual content.
A redirect requires an additional HTTP request-response cycle and delays the page load. Remove unnecessary redirects, especially if they are slowing access to a home or landing page.
6. Invalid HTML and CSS
Writing HTML and CSS that complies with the W3C standards means that it will be interpreted consistently by modern browsers.
- Invalid HTML can slow down page load as the browser has to process unnecessary or invalid instructions.
- Invalid CSS can slow down the rendering time of a page.
Run your HTML through the W3C HTML Validator and CSS through the W3C CSS validator. Alternatively, you can incorporate HTML validation into your workflow with the Grunt HTML validation package and Stylelint.
7. Old-school tech
Avoid using outdated technologies like Flash, Java, and Silverlight in the browser.
Most mobile devices do not support plugins such as Flash, meaning that whatever content you use them to render may be inaccessible to your mobile users. Furthermore, these plugins are the leading cause of crashes and security incidents on pages that utilize them.
Such plugins are a legacy technology. Instead of employing them to meet your needs, create content using modern native web technologies to ensure compatibility with all devices and browsers, and to guarantee the safety of your users.
8. Synchronous JavaScript blocking the page load
Add <script>
tags just before the closing