As web developers we put a lot of time into making sure that websites we build load quickly. Why? Because it’s well established that if your website loads slowly, you lose visitors. Which depending on the reason for your website’s existence, you will lose business. There’s tonnes of information about this online, including on this very website!
Occasionally, the question of the speed of the WordPress admin area comes up. If you’ve worked on a lot of WordPress sites you’ll probably have done a lot of trial and error on your journey to find how to make sites work how you want them to and so you’ve probably come across the odd site here or there where the admin area suddenly seems to grind to a halt.
It’s OK, we can just apply the same theory to the admin area as we do to the front end right? OK, first stop – GTMetrix
BUT WAIT!
When you try to test a page in the admin area with GTMetrix there’s a problem. GTMetrix isn’t logged into your site, and certainly isn’t an administrator. All that happens here is that you test the speed of the login page, which is normally pretty good.
Let’s get GTMetrix logged in
GTMetrix has a handy feature that will allow you to authenticate the speed test so that you can test any logged in page. The way we do this is by lending GTMetrix our session cookies so that our website thinks GTMetrix is us.
IMPORTANT: The first step is ensuring that we do this as securely as possible. Passing your browser’s session cookies could be a security risk!
To help mitigate the security risk of using session cookies, the first step to take is to create a brand new administrator user for your site and login with this user. Call it whatever you like, as soon as we’re done testing we’re going to delete this user.
Once you are logged in with the temporary test user, navigate to the page you are going to test and open up the browser console. I’m going to demonstrate this in Google Chrome.
Head to the application tab, on the left open the cookies list, and click your websites domain. This should display a list of cookies your browser currently has stored for your site.
Next, I’m going to highlight them and copy and paste in Microsoft Excel, feel free to use your spreadsheet editor of choice.
We only need the first two columns so the rest can go. In the third column, I’m then going to concatenate the cookie names and values with an “=” sign in between. To do this, I’m going to enter, for example, in cell C2
=A2&"="&B2
I’ll then copy this formula to all rows in the spreadsheet that contain my cookies, then I’m going to copy the whole list.
Back to GTMetrix, I’m going to start a new page speed test as normal, except this time I’m going to click Analysis Options. In the bottom left in the box labelled “Cookies”, paste column C from your spreadsheet. Note the ? tool tip and it’s warnings and FAQs link, worth a read.
There you have it…
OK, so now we’ve managed to generate our speed test report for the admin area of WordPress. Now what?
Well, that’s for another blog post but not at least you area able to generate the report and begin using the information for your investigations.
Once you’ve finished testing, logout from your test users account and delete the user! This will ensure that no one can use the cookies you gave to GTMetrix to gain access to your website!
Have you ever experiences a slow WordPress admin area? Share your tips in the comments!