Before today, my personal site and blog was running on WordPress, a quick and convenient solution for most.

However, for my purposes, it wasn't good enough. Here's why I decided to write my own site engine and how I decreased loading time by alot! New Blog Engine

I know, it doesn't sound reasonable to spend time on making your own blog engine, but really, I did walk through github and were trying to find something that suits me. Still, in the end, I spent just few hours on making my own, from scratch, this one right here. I'd spend more on taking something that's not quite what I need and start rewriting it.

Bells and whistles

Well, it's my personal site so I know exactly what I need and what I don't need. Having all bells and whistles that WordPress brings, causes even simplest site to have huge impact on loading times and if you're never going to use or need any of those features, you're having big overhead for no other reason than quick setup.

For example, I'm definately not going to have multiple editors or users to manage the site. I'll do it myself and myself only. I don't need templates, I'll make my own anyway. When it comes to my taste, I don't really like their fancy editor either. I prefer to use markdown to write posts.

Size and performance

Clean WP installation uses 12 MySQL tables. Add some plugins and it'll start to grow rapidly. Hell with that! I decided not to have any database. No external connections, nothing to depend on: this is what freedom is like!

And to get WordPress to be well optimized, SEO-friendly, etc. it still needs to be tuned and sometimes with all the additives, it can grow quite big - I've seen simple wordpress installations that has directory size around 100MB. Even mine had 70MB worth of files. It's huge and I know it's partly my fault, but that's what automation and convienency does to you: you don't seem to clean up.

This site runs on 8-core Xeon with 32GB RAM and 2 SSD drives in RAID1. With empty cache, it used to took 5+ seconds to finish loading. Now, slowest page on my site finishes in 346ms, and most of it is due to fonts from CDN.

Customizing

Yes, WordPress does have a lot of plugins and templates to select from, but again those comes with a price: your site gets bigger and each plugin/template can again bring their own extra features that you're not going to need.

From my perspective: I'm grown-up so that means I don't do PHP. Then again, I want to be aware of whats under the hood of my site, how it's made and sometimes customize things for my need. But, me, coding something for WordPress in 2017? In PHP? Not going to happen.

By not having huge codebase to work with, it's eventually faster and easier to customize your site. And you're in charge, really. I could spend more time on just navigating through WP files than on coding this engine.

What did I end up with

Taking everything to consideration, I spent few hours coding + writing time of this post and I'm happy with the results. Heck, most of this time was consumed by building front-end, which I don't do that often.

So, obviously, if you know me, you know it's running Node.JS. But what else?

Nothing really. Filesystem is now my database. Nothing fancy and feels so 1997 but it fits exactly what I need. All my blog posts are on separate txt files that has contents in markdown syntax. Those files are being read and parsed only on changes. Everything that's being served, is already in memory. You open a blog post and nothing is being read from hard drive. Can it get faster than that? Nope.

All the metainfo, slugified url, published date, tags etc. for one post are stored in single JS object:

{
    title: 'My new post',
    slug: 'my-new-post',
    published: { year: 2017, month: 3, day: 7 },
    tags: ['keywords', 'are', 'here'],
    raw: fs.readFileSync(..slug...txt)
}

Which then will be parsed, having new keys and values assigned to the same object.

And I still have customization options. I still can add commenting possibility in the future without having to change anything in this logic.

Results

Let the numbers speak for themselves.

Size: Directory + Database

Without images

Before (WordPress): 65MB
Now (Node.JS): 256KB (nice number)

With images

Before (WordPress): 72MB
Now (Node.JS): 1.1MB

Finish speed (no cache)

Blog index

Before (WordPress): 7037ms
Now (Node.JS): 325ms

Blog post (same content on both)

Before (WordPress): 2360ms
Now (Node.JS): 346ms

With cache enabled, I was able to finish loading blog index page within 120ms.