GitHub Pages with a custom root domain loses you 35% of your visitors

Update: This is no longer true since at least August 2014. GitHub fixed this!

If you have a website on GitHub Pages that sits on a root domain (a domain that isn’t a subdomain), you’re in trouble.

Have you ever noticed how your site loads slowly sometimes? It’s not your connection.

Some scary stats

GitHub Pages with a custom domain is unbelievably slow.

Visitors to this site’s index page have an average page load time of 3.5 seconds. 70% of those are here for the first time. 3.5 ÷ 70% = 5. So first time visitors have an average page load time of 5 seconds. 1

This website is now off of GitHub Pages and loads in 700 milliseconds on a first visit, gaining over 4 seconds.

What do you lose when you add 4 seconds of delay on a first time visit?

Source

Of the visitors that visit your GitHub Pages site for the first time, 35% more of them won’t bother to open another page. Your bounce rate is doubled.

Where does this problem come from?

Anselm Hannemann has a good rundown of the problem, including a note from GitHub support. When a domain has a DNS A record (pointing to GitHub Pages’ IP), GitHub’s DDoS mitigation technology has no alternative than to make a long redirect

What I’ve noticed is that sometimes it’s not just a big long redirect but multiple 302 redirects. This behavior isn’t documented anywhere it seems.

5 seconds seems big. When I notice a slow GitHub Pages website the wait seems to be more around 3 seconds, and that’s what I usually see in Chrome’s Network panel. The thing is, InstantClick’s visitors are spread around the world, my guess is this is what tilts the balance. 2

The solution

The short solution is, instead of using yourdomain.com, use www.yourdomain.com. 3

If you want to keep your clean www-less domain, you’ll have to move off of GitHub Pages, and/or use CloudFlare who can have a CNAME record on the root domain. The latter has the advantage of making your website super-fast across the globe with its edge caching feature.

Updates: 1. Thanks to Hacker News’s dknecht who pointed out that CloudFlare can have a CNAME record on the root domain, which should solve GitHub Pages’ performance issues. 2. I previously recommended moving to Neocities, but they currently have similar problems. :(

This website uses a Digital Ocean VPS 4 with CloudFlare.

By the way, you should definitively check out InstantClick if you care about web performance.

Footnotes

  1. I couldn’t find a way to get this number from Google Analytics directly. The difference with subsequent page load times isn’t counted here, because with InstantClick (check it out) subsequent page loads usually take zero second. 
  2. The 5 top-visiting countries are USA (22%), France (9%), Russia (7%), China (6%) and UK (6%). I’m personally located in France. 
  3. Update: I previously recommended putting a CNAME from the root domain to the www domain here. But as pointed out by pilif on Hacker News that’s not possible (unless you use CloudFlare). It’s what’s causing the issue with GitHub Pages in the first place actually, duh
  4. They offer a coupon code valid through May by the way, DODROPLET will give you $10 of credits. Also valid for existing customers.