Skip to content

Commit a912a4d

Browse files
authoredSep 17, 2018
Make initial HTML smaller (#5183)
1 parent e2d331d commit a912a4d

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed
 

‎client/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ envConfig.setConfig({
4949
const asPath = getURL()
5050

5151
const pageLoader = new PageLoader(buildId, prefix)
52-
window.__NEXT_LOADED_PAGES__.forEach(({ route, fn }) => {
53-
pageLoader.registerPage(route, fn)
52+
window.__NEXT_LOADED_PAGES__.forEach(([r, f]) => {
53+
pageLoader.registerPage(r, f)
5454
})
5555
delete window.__NEXT_LOADED_PAGES__
5656
window.__NEXT_REGISTER_PAGE = pageLoader.registerPage.bind(pageLoader)

‎server/document.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,7 @@ export class NextScript extends Component {
178178
static getInlineScriptSource (documentProps) {
179179
const { __NEXT_DATA__ } = documentProps
180180
const { page, pathname } = __NEXT_DATA__
181-
182-
return `
183-
__NEXT_DATA__ = ${htmlescape(__NEXT_DATA__)}
184-
__NEXT_LOADED_PAGES__ = []
185-
186-
__NEXT_REGISTER_PAGE = function (route, fn) {
187-
__NEXT_LOADED_PAGES__.push({ route: route, fn: fn })
188-
}${page === '_error' ? `
189-
190-
__NEXT_REGISTER_PAGE(${htmlescape(pathname)}, function() {
191-
var error = new Error('Page does not exist: ${htmlescape(pathname)}')
192-
error.statusCode = 404
193-
194-
return { error: error }
195-
})`: ''}
196-
`
181+
return `__NEXT_DATA__ = ${htmlescape(__NEXT_DATA__)};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}${page === '/_error' ? `;__NEXT_REGISTER_PAGE(${htmlescape(pathname)},function(){var e = new Error('Page does not exist: ${htmlescape(pathname)}');e.statusCode=404;return {error:e}})`:''}`
197182
}
198183

199184
render () {

0 commit comments

Comments
 (0)
Please sign in to comment.