Content: Can I break the generated db.json into smaller files?

Created on 18 Jun 2020  路  4Comments  路  Source: nuxt/content

Is it possible to have my generated dist\_nuxt\content\db.json file broken into smaller files?
I'm generating my application using nuxt generate.

Problem
Currently inside my \content folder I have divided my content into a few languages (eg. \en, \br, \es and so on...).
So, on the user first access the whole db.json is downloaded and it contains all languages that the user will definitely not need at that moment.

I think what I'm trying to accomplish here is to lazy-load chunks of content.

Anyone able to give me some direction?

Thank you so much in advance!

question

Most helpful comment

Hey @jonathanmach,

Actually breaking the db.json into multiple files is not possible at the moment.

However, by using Nuxt.js v2.13 full-static, the db.json is loaded only when $content is called outside of asyncData and fetch, basically only when calling search in a method.

Therefore, having a single db.json does not cause any performance issues on page load.

All 4 comments

Hey @jonathanmach,

Actually breaking the db.json into multiple files is not possible at the moment.

However, by using Nuxt.js v2.13 full-static, the db.json is loaded only when $content is called outside of asyncData and fetch, basically only when calling search in a method.

Therefore, having a single db.json does not cause any performance issues on page load.

Is this type of optimization on the roadmap? The size of the file can quickly get prohibitively large, even if it's not requested until you need it. On my personal site with approximately 10 blog posts, the file is close to 2MB. This will scale linearly with the # of content files, it could easily approach 10MB or greater when you get into the 40-50 content file range.

The home-grown solution that I replaced used a small manifest file (generated at build time) that did not contain the full text that could be used for generating lists of blog posts and for searching for blog posts, say for a given tag. And then dynamic webpack chunks for full-text markdown contents.

Could a manifest-type approach be looked into where a smaller set of data is loaded to perform most operations (short of full-text-search), followed by larger loads only when needed?

Oops! I was still on an older version (1.2) of this package, just upgraded to 1.4 and it looks like there is a manifest approach of sorts being used now. Awesome work!

Hm. Ok maybe I spoke too soon,. I was noticing the manifest-type approach in dev builds, but after nuxt generate I'm still seeing a 2MB db.json file being pulled in on the first content-driven page

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodrigocvb picture rodrigocvb  路  3Comments

pi0 picture pi0  路  3Comments

giticon picture giticon  路  3Comments

Rednas83 picture Rednas83  路  3Comments

katerlouis picture katerlouis  路  3Comments