Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ascoders/weekly
Browse files Browse the repository at this point in the history
  • Loading branch information
ascoders committed Jan 10, 2022
2 parents f3a50ce + c8c9f7c commit 6e36e81
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 前沿技术/1.精读《js 模块化发展》.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ YUI3 的 sandbox 像极了差不多同时出现的 AMD 规范,但早期 yahoo

对于 js 模块化,最近出现的 `<script type="module">` 方式,虽然还没有得到浏览器原生支持,但也是我比较看好的未来趋势,这样就连 webpack 的拆包都不需要了,直接把源代码传到服务器,配合 http2.0 完美抛开预编译的枷锁。

上述三中方案都不依赖预编译,分别实现了 html、css、js 模块化,相信这就是未来。
上述三种方案都不依赖预编译,分别实现了 html、css、js 模块化,相信这就是未来。

### 模块化标准推进速度仍然缓慢

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### 解析阶段

首先 renderer process 主线程会解析 HTML 文本为 DOM(Document Object Model),只译为中文就是文档对象模型,所以首先要把文本结构化才能继续处理。不仅是浏览器,代码的解析也得首先经历 Parse 阶段。
首先 renderer process 主线程会解析 HTML 文本为 DOM(Document Object Model),直译为中文就是文档对象模型,所以首先要把文本结构化才能继续处理。不仅是浏览器,代码的解析也得首先经历 Parse 阶段。

对于 HTML 的 link、img、script 标签需要加载远程资源的,浏览器会调用 network thread 优先并行处理,但遇到 script 标签就必须停下来优先执行,因为 js 代码可能会改变任何 dom 对象,这可能导致浏览器要重新解析。所以如果你的代码没有修改 dom 的副作用,可以添加 async、defer 标签,或 JS 模块的方式使浏览器不必等待 js 的执行。

Expand Down

0 comments on commit 6e36e81

Please sign in to comment.