Unverified Commit a912a4d9 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Make initial HTML smaller (#5183)

parent e2d331db
...@@ -49,8 +49,8 @@ envConfig.setConfig({ ...@@ -49,8 +49,8 @@ envConfig.setConfig({
const asPath = getURL() const asPath = getURL()
const pageLoader = new PageLoader(buildId, prefix) const pageLoader = new PageLoader(buildId, prefix)
window.__NEXT_LOADED_PAGES__.forEach(({ route, fn }) => { window.__NEXT_LOADED_PAGES__.forEach(([r, f]) => {
pageLoader.registerPage(route, fn) pageLoader.registerPage(r, f)
}) })
delete window.__NEXT_LOADED_PAGES__ delete window.__NEXT_LOADED_PAGES__
window.__NEXT_REGISTER_PAGE = pageLoader.registerPage.bind(pageLoader) window.__NEXT_REGISTER_PAGE = pageLoader.registerPage.bind(pageLoader)
......
...@@ -178,22 +178,7 @@ export class NextScript extends Component { ...@@ -178,22 +178,7 @@ export class NextScript extends Component {
static getInlineScriptSource (documentProps) { static getInlineScriptSource (documentProps) {
const { __NEXT_DATA__ } = documentProps const { __NEXT_DATA__ } = documentProps
const { page, pathname } = __NEXT_DATA__ const { page, pathname } = __NEXT_DATA__
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}})`:''}`
return `
__NEXT_DATA__ = ${htmlescape(__NEXT_DATA__)}
__NEXT_LOADED_PAGES__ = []
__NEXT_REGISTER_PAGE = function (route, fn) {
__NEXT_LOADED_PAGES__.push({ route: route, fn: fn })
}${page === '_error' ? `
__NEXT_REGISTER_PAGE(${htmlescape(pathname)}, function() {
var error = new Error('Page does not exist: ${htmlescape(pathname)}')
error.statusCode = 404
return { error: error }
})`: ''}
`
} }
render () { render () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment