If you're a creator using Ghost CMS (or a Ghost theme developer), you might want your website to be fast to provide a great experience for your users. There are many ways to optimize the performance of a Ghost website. Today, I want to talk about one way that seems to be under looked according to this search: by optimizing card assets.
One thing I absolutely love about Ghost is that they offer so many tools to enhance your post content: buttons, bookmarks, galleries, headers, products, audio, video, and more.
Open your theme's package.json file and check if you have the
card_assets property in it.
If you can't find this setting inside your theme's package.json file, the default value for this property has been
true since Ghost 5.0.
cards.min.css and a
Take a look at these files here (5.0 kB) and here (2.0 kB) for the demo.ghost.io website. There's a lot of code, isn't it? 😲
But, did you know that you can exclude the features you don't use? I did, and my cards.min.css file is down to 1.6 kB, a reduction of 3.4 kB (68%)! And my cards.min.js file has been completely deleted!
It turns out there's an exclude option you can use to remove the default card implementations in Ghost.
excludelist, it doesn't mean you can't use this feature anymore! It only means that your local theme is now 100% responsible for implementing the necessary code.
For example, I still have quotes, galleries and buttons in some of my posts, don't worry! 😅
You can also disable all cards assets by setting
card_assets to false.
A simple configuration could immediately reduce your website's response time. Isn't that awesome? 🤗
What files are automatically included in the cards.min.css and cards.min.js files?
As of July 31st, 2022, the included files were:
What would a configuration that disables all default implementations look like?
If you listed all the previous card names, it would look something like below:
Can I use an allowlist (include) instead of a disallow list (exclude)?
According to the current CardAssetService implementation, you can, but I haven't been able to get it to work yet. Let me know if you succeed! 😋