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

[1.0] optimizations around prefetching page resources #1133

Merged
merged 29 commits into from
Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c0ae4f9
Copy cache-dir files into site's .cache
KyleAMathews Jun 7, 2017
291b69c
Got new loader/componentrenderer working in development
KyleAMathews Jun 7, 2017
f92fdb9
Use ComponentRenderer for rendering
KyleAMathews Jun 7, 2017
f6c3112
On demand loading of async page resources working for prod builds
KyleAMathews Jun 7, 2017
d0ae0e6
Merge branch '1.0' into queue-requests
KyleAMathews Jun 7, 2017
0c8abd7
Use script loader so loading scripts don't block rendering
KyleAMathews Jun 7, 2017
69f60ae
Add gatsby-module-loader to replace bundle-loader to add ability to d…
KyleAMathews Jun 8, 2017
1f44c11
Split out loading/executing resources into functions
KyleAMathews Jun 8, 2017
f289c38
Add prefetcher
KyleAMathews Jun 8, 2017
389f7e9
changing order to see if it fixes not removing event handler
KyleAMathews Jun 8, 2017
b0f2c88
Just don't have a loader for now
KyleAMathews Jun 8, 2017
d4a841b
Updates to service worker plugin
KyleAMathews Jun 9, 2017
f2f368b
Add tests for find-page + make it work with prefixed links
KyleAMathews Jun 9, 2017
9ae6a60
Proritize links that mount first i.e. are higher on the page
KyleAMathews Jun 9, 2017
7766b77
Wait for all links to mount before fetching so resource count is correct
KyleAMathews Jun 9, 2017
ab5da7f
Add plop template for adding new example sites
KyleAMathews Jun 10, 2017
c7dd9b1
Add plugin for nprogress to auto show when page loading is delayed
KyleAMathews Jun 10, 2017
4644ea7
Don't break layout if there's no content
KyleAMathews Jun 10, 2017
aeb9a77
Log at end of build how long build took
KyleAMathews Jun 10, 2017
8162a91
Not using this package
KyleAMathews Jun 10, 2017
bbf5302
Merge remote-tracking branch 'origin/1.0' into queue-requests
KyleAMathews Jun 10, 2017
19f7c72
Remove logging + run format
KyleAMathews Jun 10, 2017
a1fd507
Add the nprogress plugin
KyleAMathews Jun 10, 2017
ce5ca59
Fix some emitter code
KyleAMathews Jun 10, 2017
ab0e3f4
Make it easy to override the default color of the nprogress bar
KyleAMathews Jun 10, 2017
33e9e8e
Fix check on variable
KyleAMathews Jun 10, 2017
c6b486a
Fix prefetching
KyleAMathews Jun 10, 2017
6cac6e1
Fix test
KyleAMathews Jun 10, 2017
fd01c58
Add nprogress plugin to list
KyleAMathews Jun 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some emitter code
  • Loading branch information
KyleAMathews committed Jun 10, 2017
commit ce5ca5984a31ed05edec7649de3de53f0739b7c6
8 changes: 2 additions & 6 deletions packages/gatsby/src/cache-dir/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const prefetcher = require(`./prefetcher`)({
})
},
})
emitter.on(`ON_PRE_LOAD_PAGE_RESOURCES`, e => {
emitter.on(`onPreLoadPageResources`, e => {
prefetcher.onPreLoadPageResources(e)
})
emitter.on(`ON_POST_LOAD_PAGE_RESOURCES`, e => {
emitter.on(`onPostLoadPageResources`, e => {
prefetcher.onPostLoadPageResources(e)
})

Expand Down Expand Up @@ -64,9 +64,7 @@ const fetchResource = (resourceName, cb = () => {}) => {
: asyncRequires.json[resourceName]

// Download the resource
console.time(`download resource ${resourceName}`)
resourceFunction((err, executeChunk) => {
console.timeEnd(`download resource ${resourceName}`)
resourceStrCache[resourceName] = executeChunk
cb(err, executeChunk)
})
Expand All @@ -81,9 +79,7 @@ const getResourceModule = (resourceName, cb) => {
if (err) {
cb(err)
} else {
console.time(`execute chunk ${resourceName}`)
const module = preferDefault(executeChunk())
console.timeEnd(`execute chunk ${resourceName}`)
resourceCache[resourceName] = module
return cb(err, module)
}
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/cache-dir/production-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const navigateTo = pathname => {
// a second, navigate immediately.
function eventHandler(e) {
if (e.page.path === pathname) {
emitter.off(`onPostLoadPageResources`, eventHandler)
clearTimeout(timeoutId)
window.___history.push(pathname)
}
Expand Down