Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split page metadata so can lazy load it and reduce the initial JS #4746

Closed
chmac opened this issue Mar 28, 2018 · 6 comments
Closed

Split page metadata so can lazy load it and reduce the initial JS #4746

chmac opened this issue Mar 28, 2018 · 6 comments
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@chmac
Copy link
Contributor

chmac commented Mar 28, 2018

Summary: Allow the data.json file to be loaded in shards for sites with large numbers of pages.

History

Once #4715 lands:

  • data.json contains a map of all paths to data file names
    • File names include a content hash
  • data.json is loaded after the page has finished rendering

Sharding was also discussed in #4626.

Changes

Rather than loading data.json as a single file, it could be split into multiple files based on a simple sharding mechanism, for example:

const calculateShardNameForId(shardLength: int, id: string) => md5(id).substr(0, shardLength)

@KyleAMathews mentioned:

Ideally you'd shard by something like path names so a shard for /blog/*, as those are likely to be needed together.

@pieh shared:

Just to give more info - when I run my tests against https://github.com/freeCodeCamp/guides (~2800 pages) - gzipped "webpackified" data.json is 141KB - this surely won't scale very nice for 100 000 pages sites, but up to 10 000 I think this shouldn't be that much of a issue

Rationale

  • On very large sites (>1k pages, or >10k pages) the data.json file can become large.
  • It must be fully loaded before prefetching can begin.
  • Splitting it into chunks could allow faster prefetching, and require less data over the wire, on very large sites.

This is a low priority enhancement.

@m-allanson m-allanson added help wanted Issue with a clear description that the community can help with. 🏷 type: feature labels Jul 10, 2018
@KyleAMathews
Copy link
Contributor

I have an open PR for this #6651

@KyleAMathews
Copy link
Contributor

Definitely needs done for Gatsby to scale to larger sites.

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 3, 2019
@gatsbot
Copy link

gatsbot bot commented Jan 3, 2019

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@thibautRe thibautRe added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Jan 4, 2019
@KyleAMathews KyleAMathews changed the title Allow optional sharding of data.json Split page metadata so can lazy load it and reduce the initial JS Jan 9, 2019
@KyleAMathews
Copy link
Contributor

gatsbyjs.org's page metadata chunk is up to 451kbs yikes 😬

@m-allanson
Copy link
Contributor

Related to #13004

@m-allanson
Copy link
Contributor

Fixed in #13004, and available in gatsby@2.9.0 🎉 Huge thanks to @Moocar and everyone involved in reviewing and testing this feature 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants