-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
perf(gatsby): Minify page-data #35578
Conversation
We left it unminified in the past as it's nice to be able to easily read the files on disk + with gzip it doesn't make much difference afaik. What is the size difference of the file over the network w/ gzip? |
Given the useful data in it is already minified (the query result), and other files (static queries, etc) are too, and also most people who will be looking at it would be using it through a tool that supports beautifying the file, I'm unsure whether it makes sense to do it for that reason. Regarding stats, on an example file it saved 14 bytes gzipped (and around 4x that in raw file size). It's not a massive saving, but for a site with 20k pages that's over 1mb saved on disk. If a page links to ~20 other pages (such as a blog index or similar), that then becomes 292 bytes saved. For 50k page loads, that's then 15mb. It's a minor saving but it somewhat feels like it doesn't have downsides, so it's free bytes. If you'd rather keep it as-is without minifying it that's fine, I only made the PR because I noticed the file wasn't minified in my network tab and made a PR to change that as I didn't personally see a downside. If it's wanted behaviour that's a different matter. |
I think these are good arguments in favor of doing that change 👍 |
Yeah I think I left it unminified early on with Gatsby v1 as I was looking at the generated files a lot to debug stuff. But these days, query running is a very mature sub-system so it's not common to look directly at the page-data.json files. |
Description
This minifies the page-data.json files, rather than including whitespaces and newlines. This is a very minor change regarding bytes of the file, but there's really no reason not to do this. The file was also already partially minified, as the final closing brace would end up at the end of the preceding line. Other JSON files outputted by Gatsby are all minified, so this brings page-data in line with the rest.