博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
next. js_Next.js应用程序捆绑
阅读量:2508 次
发布时间:2019-05-11

本文共 2063 字,大约阅读时间需要 6 分钟。

next. js

When you view the page source of a Next.js app, you can see a bunch of JavaScript files being loaded:

当您查看Next.js应用程序的页面源代码时,您会看到一堆正在加载JavaScript文件:

Let’s start by putting the code in an to get it formatted better, so we humans can get a better chance at understanding it:

让我们开始将代码放入以使其格式更好,以便我们人类可以更好地了解它:

    

Home page

We have 4 JavaScript files being declared to be preloaded in the head, using rel="preload" as="script":

我们使用rel="preload" as="script"将4个JavaScript文件声明为要在head rel="preload" as="script"

  • /_next/static/development/pages/index.js (96 LOC)

    /_next/static/development/pages/index.js LOC)

  • /_next/static/development/pages/_app.js (5900 LOC)

    /_next/static/development/pages/_app.js LOC)

  • /_next/static/runtime/webpack.js (939 LOC)

    /_next/static/runtime/webpack.js LOC)

  • /_next/static/runtime/main.js (12k LOC)

    /_next/static/runtime/main.js LOC)

This tells the browser to start loading those files as soon as possible, before the normal rendering flow starts. Without those, scripts would be loaded with an additional delay and this improves the page loading performance.

这告诉浏览器在正常渲染流程开始之前尽快开始加载这些文件。 没有这些脚本,脚本将被额外延迟加载,从而提高了页面加载性能。

Then those 4 files are loaded at the end of the body, along with /_next/static/development/dll/dll_01ec57fc9b90d43b98a8.js (31k LOC), and a JSON snippet that sets some defaults for the page data:

然后将这4个文件以及/_next/static/development/dll/dll_01ec57fc9b90d43b98a8.js LOC)和一个设置了页面数据某些默认值的JSON片段一起加载到body的末尾:

The 4 bundle files loaded are already implementing one feature called code splitting. The index.js file provides the code needed for the index component, which serves the / route, and if we had more pages we’d have more bundles for each page, which will then only be loaded if needed - to provide a more performant load time for the page.

加载的4个捆绑包文件已经实现了一种称为代码拆分的功能。 index.js文件提供了index组件所需的代码(用于/路由),如果我们有更多的页面,我们将为每个页面提供更多的包,然后仅在需要时才加载它们-以提供更高的性能页面的加载时间。

翻译自:

next. js

转载地址:http://pmqgb.baihongyu.com/

你可能感兴趣的文章
入门阶段
查看>>
Android中使用http协议访问网络
查看>>
vs win32 & MFC 指针默认位置
查看>>
Join 与 CountDownLatch 之间的区别
查看>>
js存cookie
查看>>
vc6下dll调试
查看>>
Ubuntu apt常用命令
查看>>
struts2 配置(部分)
查看>>
python代码迷之错误(ModuleNotFoundError: No module named 'caffe.proto')
查看>>
nodejs adm-zip 解压文件 中文文件名乱码 问题解决
查看>>
MapReduce-文本输入
查看>>
<Bootstrap> 学习笔记六. 栅格系统使用案例
查看>>
可能的出栈序列问题
查看>>
vector--C++ STL 学习
查看>>
蜕变成蝶~Linux设备驱动之异步通知和异步I/O
查看>>
jquery简单开始
查看>>
IOS 在不打开电话服务的时候,可以响应服务器的推送消息,从而接收服务器的推送消息...
查看>>
置顶的博客
查看>>
ionic2 native app 更新用户头像暨文件操作
查看>>
SQL Server R2 地图报表制作(一)
查看>>