turbin3
BuSo Pro
- Joined
- Oct 9, 2014
- Messages
- 613
- Likes
- 1,287
- Degree
- 3
I'm kind of a page speed fiend, so I figured I might as well put up a post with a few golden nuggets I've come across as I've educated myself on the subject, and the things I've learned through trial and error. I'm sure a lot of you guys already know most of this, and I'm sure most of it won't be anything new, but if it can at least help some newbies, I figured it was worth posting. Sorry in advance. It's practically a novel, and maybe a bit disorganized as I'm a bit delirious after work today.
While I'm not going to go into specific details as to why fast page load times are important, we all know they are a ranking factor and can directly impact your site's engagement metrics (bounce, exit rate, time on page, etc.). Also, as mobile traffic is becoming more and more common, page load times become even more important. With mobile internet traffic, there are 4 additional steps in the process for a mobile device loading a web page, so desktop load times are exponentially increased when it comes to mobile. While many people go by the age old rule of "3 seconds or less" for desktop, keep in mind, it could be significantly longer load times on mobile, so that simply might not be good enough.
Anyways, getting to the meat and potatoes. Most of this will be from the standpoint of Wordpress, since I'm guessing most of us are building and running Wordpress sites pretty frequently. To start off with, if I have a page I'm trying to optimize, I'll first run it through http://gtmetrix.com/dashboard.html and benchmark its existing performance. You'll get a Google Page Speed grade as well as a Yslow grade, both with slightly different optimization recommendations. Things to take note of:
Reducing Page Size:
To reduce page size, there are several main areas you'll want to look to accomplish this. Usually the quickest and easiest with GTMetrix is to look for the "Optimize Images" recommendation. If it's less than 100%, click on it to expand and show the details. The awesome thing with this site is, if there are images that can be further compressed to reduce size, they will automatically do this with lossless compression and actually PROVIDE the optimized image for you! Super cool. So right off the bat, you can download these images, rename them identical to your existing on page images, upload them to your server, and you've already made an impact! In all the times I've used these images, I have yet to see any decrease in image quality or resolution.
The general idea with the GTMetrix recommendations, is with any of the recommendation sections that are below 100%, you want to implement as many of those changes they recommend and push that section as close to 100%. Through doing this, depending on the various sections you'll be making incremental gains in reducing page size, reducing the number of HTTP requests, improving the efficiency and parsing of on page scripting, etc., all leading to a faster and better rendering page.
Other areas for reducing page size are:
Quick word of advice. Create a GTMetrix account, and you can save your benchmark run. When you run it, click "Page Settings" near the top left of the page, and click "Save Page". Each time you feel you've made significant progress implementing some changes, such as the minify changes above, click "Re-Test Page" and see what effect your changes had.
Reducing HTTP Requests:
This is probably one of the most overlooked areas. Some of my clients' sites are utterly ridiculous in how overly bloated their on site scripting is, to the point of having a ridiculous number of HTTP requests. The thing to keep in mind here is, additional requests take time that you cannot afford. Also, with a lot of CMS' (don't even get me started on freakin Drupal!), and with a lot of aftermarket themes, scripting is excessive, redundant, and can add a lot of overhead here. These are factors you should consider when purchasing a theme. The theme may look great, but it probably won't matter if it's a convoluted mess "under the hood". Things that add to HTTP requests:
CSS. Same thing. Consolidate your CSS files if possible. I realize this is probably more trouble than it's worth with a lot of out of the box themes, but if it's not, do it.
Number of images. This is usually going to be one of the quicker and easier areas to reduce number of HTTP requests. Every single, separate image will add an additional request. The quickest way to make a big impact across the whole site is to think about common images that are present on most pages:
As far as what a reasonable number of requests is, I have my own opinions. I'll give you both ends of the spectrum, as there's no real "rule" here. Some of my sites I've had as low as 6-8 requests, but I usually try to achieve at least 10-20 maximum, if possible. Sometimes, if the other areas of the site are very efficient and fast, such as the host, overall page size, usage of a CDN, etc. you can get away with a lot more. Some sites have quite a bit more on-page scripting and end up with 30-50 HTTP requests, while still being fast. Again, there's not really a hard and fast rule here. Some of my current clients' sites are on the pretty ridiculous end of the spectrum. One previous client had something like 200-210 requests. Bounce rate was exorbitant, engagement metrics almost non-existent, rankings sucked, and they went nowhere fast. Ultimately, they paid me to provide them recommendations on the obvious, ultimately to ignore that advice and continue on into oblivion. *Pro tip*: Don't hire a professional, argue with them, and then ignore their advice, all while expecting success. Many of my current clients are around the 80-140 request range, which is extremely bloated IMO. Ideally, I'd like to see those numbers cut substantially, to 50 requests or less. It's been my experience that much beyond 40-50 requests and the total number of requests is definitely a significant factor that is probably holding your page load times back.
Anyways, GTMetrix has great documentation on all of their other recommendations, so I won't go into detail on a lot of the other options (unless someone has specific questions about any of them). Some other things to keep an eye on, that can help you in pinpointing issues or prioritizing them. The Timeline tab will show you a timeline of how the page loads, including all of its on page elements. Many will load simultaneously, but you will also see some that stand out, that take significantly longer to load. Looking at this chart, I'll usually start off looking at any of the major spikes to get a sense of what those elements are, and how that might affect the way I approach optimizing the page. If most of the spikes are images, I might be a bit more heavily focused on image optimization, finding different images that are smaller in file size, consolidating images with a CSS sprite, etc. If it's scripting, maybe I might look to combine scripts into a fewer number of files if it's not too difficult and if it isn't going to screw up some proprietary theme design. Also, I'll look at overall page size and the sizes of the files being loaded. If any stand out as significantly larger than others, I might also look to simply eliminate certain files from the page. For example, some CMS themes may have certain background or unseen scripting elements present, that aren't really in use. Sometimes it's a carryover from other pages of the site, but maybe some of the scripted elements (social sharing widgets) aren't necessarily being used at a "global level" on every page of the site. If I ever come across things like that, I might look to eliminate the scripts being called on that one page, that aren't in use.
Mobile:
Lastly, try running your site through GTM using a few of the different server options. Under the Page Settings section in the top left, you can choose the server location, browser, and connection type. Try setting it to a 3G connection, then re-test the page to see what changes. Any significant increase in page load times? If so, where did the increase come from? Look at the timeline and how it differs from the previous run (this is why you want to save runs). Also, did the overall page size change? How about the number of HTTP requests? Sometimes between desktop and mobile you may find different elements that load on both or provide an impediment. Go through the same areas for improvement with the mobile run, and see if there's any significant improvements to be made there as well.
While I'm not going to go into specific details as to why fast page load times are important, we all know they are a ranking factor and can directly impact your site's engagement metrics (bounce, exit rate, time on page, etc.). Also, as mobile traffic is becoming more and more common, page load times become even more important. With mobile internet traffic, there are 4 additional steps in the process for a mobile device loading a web page, so desktop load times are exponentially increased when it comes to mobile. While many people go by the age old rule of "3 seconds or less" for desktop, keep in mind, it could be significantly longer load times on mobile, so that simply might not be good enough.
Anyways, getting to the meat and potatoes. Most of this will be from the standpoint of Wordpress, since I'm guessing most of us are building and running Wordpress sites pretty frequently. To start off with, if I have a page I'm trying to optimize, I'll first run it through http://gtmetrix.com/dashboard.html and benchmark its existing performance. You'll get a Google Page Speed grade as well as a Yslow grade, both with slightly different optimization recommendations. Things to take note of:
- Page load time
- Total page size
- Total number of requests (HTTP requests)
Reducing Page Size:
To reduce page size, there are several main areas you'll want to look to accomplish this. Usually the quickest and easiest with GTMetrix is to look for the "Optimize Images" recommendation. If it's less than 100%, click on it to expand and show the details. The awesome thing with this site is, if there are images that can be further compressed to reduce size, they will automatically do this with lossless compression and actually PROVIDE the optimized image for you! Super cool. So right off the bat, you can download these images, rename them identical to your existing on page images, upload them to your server, and you've already made an impact! In all the times I've used these images, I have yet to see any decrease in image quality or resolution.
The general idea with the GTMetrix recommendations, is with any of the recommendation sections that are below 100%, you want to implement as many of those changes they recommend and push that section as close to 100%. Through doing this, depending on the various sections you'll be making incremental gains in reducing page size, reducing the number of HTTP requests, improving the efficiency and parsing of on page scripting, etc., all leading to a faster and better rendering page.
Other areas for reducing page size are:
- Minify CSS
- Minify HTML
- Minify Javascript
- Enable gzip Compression
Quick word of advice. Create a GTMetrix account, and you can save your benchmark run. When you run it, click "Page Settings" near the top left of the page, and click "Save Page". Each time you feel you've made significant progress implementing some changes, such as the minify changes above, click "Re-Test Page" and see what effect your changes had.
Reducing HTTP Requests:
This is probably one of the most overlooked areas. Some of my clients' sites are utterly ridiculous in how overly bloated their on site scripting is, to the point of having a ridiculous number of HTTP requests. The thing to keep in mind here is, additional requests take time that you cannot afford. Also, with a lot of CMS' (don't even get me started on freakin Drupal!), and with a lot of aftermarket themes, scripting is excessive, redundant, and can add a lot of overhead here. These are factors you should consider when purchasing a theme. The theme may look great, but it probably won't matter if it's a convoluted mess "under the hood". Things that add to HTTP requests:
- Scripting (Javascript, Jquery, etc.)
- External styling elements (CSS)
- Number of images
CSS. Same thing. Consolidate your CSS files if possible. I realize this is probably more trouble than it's worth with a lot of out of the box themes, but if it's not, do it.
Number of images. This is usually going to be one of the quicker and easier areas to reduce number of HTTP requests. Every single, separate image will add an additional request. The quickest way to make a big impact across the whole site is to think about common images that are present on most pages:
- Header
- Navigation
- Footer
- Social icons
- Sidebar
As far as what a reasonable number of requests is, I have my own opinions. I'll give you both ends of the spectrum, as there's no real "rule" here. Some of my sites I've had as low as 6-8 requests, but I usually try to achieve at least 10-20 maximum, if possible. Sometimes, if the other areas of the site are very efficient and fast, such as the host, overall page size, usage of a CDN, etc. you can get away with a lot more. Some sites have quite a bit more on-page scripting and end up with 30-50 HTTP requests, while still being fast. Again, there's not really a hard and fast rule here. Some of my current clients' sites are on the pretty ridiculous end of the spectrum. One previous client had something like 200-210 requests. Bounce rate was exorbitant, engagement metrics almost non-existent, rankings sucked, and they went nowhere fast. Ultimately, they paid me to provide them recommendations on the obvious, ultimately to ignore that advice and continue on into oblivion. *Pro tip*: Don't hire a professional, argue with them, and then ignore their advice, all while expecting success. Many of my current clients are around the 80-140 request range, which is extremely bloated IMO. Ideally, I'd like to see those numbers cut substantially, to 50 requests or less. It's been my experience that much beyond 40-50 requests and the total number of requests is definitely a significant factor that is probably holding your page load times back.
Anyways, GTMetrix has great documentation on all of their other recommendations, so I won't go into detail on a lot of the other options (unless someone has specific questions about any of them). Some other things to keep an eye on, that can help you in pinpointing issues or prioritizing them. The Timeline tab will show you a timeline of how the page loads, including all of its on page elements. Many will load simultaneously, but you will also see some that stand out, that take significantly longer to load. Looking at this chart, I'll usually start off looking at any of the major spikes to get a sense of what those elements are, and how that might affect the way I approach optimizing the page. If most of the spikes are images, I might be a bit more heavily focused on image optimization, finding different images that are smaller in file size, consolidating images with a CSS sprite, etc. If it's scripting, maybe I might look to combine scripts into a fewer number of files if it's not too difficult and if it isn't going to screw up some proprietary theme design. Also, I'll look at overall page size and the sizes of the files being loaded. If any stand out as significantly larger than others, I might also look to simply eliminate certain files from the page. For example, some CMS themes may have certain background or unseen scripting elements present, that aren't really in use. Sometimes it's a carryover from other pages of the site, but maybe some of the scripted elements (social sharing widgets) aren't necessarily being used at a "global level" on every page of the site. If I ever come across things like that, I might look to eliminate the scripts being called on that one page, that aren't in use.
Mobile:
Lastly, try running your site through GTM using a few of the different server options. Under the Page Settings section in the top left, you can choose the server location, browser, and connection type. Try setting it to a 3G connection, then re-test the page to see what changes. Any significant increase in page load times? If so, where did the increase come from? Look at the timeline and how it differs from the previous run (this is why you want to save runs). Also, did the overall page size change? How about the number of HTTP requests? Sometimes between desktop and mobile you may find different elements that load on both or provide an impediment. Go through the same areas for improvement with the mobile run, and see if there's any significant improvements to be made there as well.