How to Make Hexo Blog Load Faster
Hello guys, today I will write article about how to make hexo blog load faster. Everything is so simple, because we will use only two hexo plugins and your hexo blog will get A score from GTMetrix so easily. So how to do this?
Hexo is a Static Html Generator which is based on NodeJS. You don’t need a database server like if you are using
Wordpress or any cms out there. Everything is just html files so you can just upload to any web server and you can just put your website into
The pros of using Hexo blog?
- Static HTML website.
- Source code is on your local computer.
- You don’t need using database server.
- You don’t need to be online to write article, internet is not required.
- You can just upload to GitHub, Netlify, etc for free hosting, webserver is not required.
- With the power of Git, you can have multiple user to contribute the website.
- Strong to handle high traffic because no computation on server side as it is just static files.
- No hacker could be hack your website if your source code is saved in private git repository.
The cons of using Hexo blog?
- There is no WYSIWYG editor
- To deploy is via command line
- Your static website could be stolen if uploaded to public repository. *
- ‘*’ Use your own webserver to prevent your content stolen.
- ‘**’ There is trick to avoid this, you can search through Google.
The basic things who can make your website slower is
image files. So you have to make sure to handle it’s files as small as possible. But don’t do it manually, because you can just waste your time. Let’s make this everything do automatically with powered of Hexo blog.
Playing with a public CDN will also useful to cache your files so your website will get more faster because your files will be cached into multiple networks to all countries so your visitor will get the nearest server to load your files automatically.
Hexo has all in one minifier plugin. This plugin will work to make minifier all your files
Here is the tutorial to use hexo-all-minifier :
- Install hexo-all-minifier
$ npm install hexo-all-minifier
For mac user there is more required library to install
$ brew install libtool automake autoconf nasm
- Add this line into your
Now your files will automatically minified when you are deploy to git. For advanced use, actually there is more configuration in their documentation. You can learn more at here.
Hexo has CDNify plugin which is you can rewrite your url assets to use your own CDN. If you are don’t have any CDN premium, you can make use CDN from github as free as powered by jsdelivr.
If you are not using GitHub pages, unfortunately you maybe will have to upload your assets manually into your premium CDN. But if you are using GitHub pages, once your website deployed to github, you already have CDN from jsdelivr, the benefit is everything is run automatically.
The benefit using
jsdelivr CDN with
- Everything automatically
- Realtime update, no need to add time parameter to avoid CDN caching
So here is the tutorial to use hexo-cdnify :
$ npm install hexo-cdnify
Add this line into your
If you are using premium CDN
if you are using GitHub pages
<GITHUB_USERNAME>with your github username.
<GITHUB_REPOSITORY_NAME>with your github repository name.
<GITHUB_BRANCH_NAME>with your branch name, for example
- Don’t forget to always use trailing slash at the end of url
Now after you deploy your hexo blog, all assets in your website will automatically use CDN. If you want to learn more features in using hexo-cdnify, you can read from their documentation at here.
If you want to test your website pagespeed, I recommend to use GTMetrix because the result of the pagespeed test is very detail. You will get
Waterfall information of result test. They also give you recomendations how to fix your website to increase the speed.
How to test the website page speed with GTMetrix :
- Visit to https://gtmetrix.com.
- Input your url address of your website.
- Click Analyze.
- Wait for a second then you will get the result test.
See in this picture below about Hexoder test in GTMetrix.
After you see that picture above, maybe you will ask why the hexoder website just getting B score in YSlow? It is because of additional 3rd party plugin of using
ShareThis. Because they don’t use CDN for js script then it will hurt the performance speed. So be careful of using 3rd party library, if you think it not so important for your website, just avoid to use it.
Hexo is the fast and powerful to create static html website for blog or portfolio. With only these two plugins, you already increase the page load speed of your website. This article is only to optimize the source code of your hexo blog.
- Why I don’t include AMP ?
- How about using Cache ?
With using Hexo, your website is static html files, so you don’t need cache anymore. Also with using CDN, you are already cache your assets files by CDN itself.
- How about using DNS Cloudflare ?
I’m not include into the list about use DNS Cloudflare because if you are using
Netlify, etc. It has already DNS features and your website surely could be accessed in all countries. But if you want to have more feature like using 3rd application easily, you can go to use cloudflare service. Also to be able to use this custom DNS with cloudflare, you will need to buy a custom domain first so you are able to configure the CNAME.
- Is there any way to make more faster ?
Actualy there is still a lot of other method to increase your website more faster. For example you have to know how to defer your css and js script and make sure you load your images with lazyload technique. There is a lot of tutorial about this defer out there, you can just search through Google. Or maybe I will write article about how to defer css and js script in the next time.
Thank you for your time to reading my article.