- Published on
25-Drawer 性能优化
- Authors
- Name
- Dendoink
- @Magiciaaaaaaaan
💡
问题 经常会发现,项目里面外部库的一大块 JavaScript
,或者选择器上的一些 CSS
规则,实际都没有用到,但是怎么找到并且优化这一部分内容呢?
coverage
代码覆盖率
1. coverage
可以提供冗余代码的细节信息。使用 Drawer
菜单或者 Command
菜单来打开它:

DevTools
的 coverage
工具可以跟踪当前加载的 JS
和 CSS
文件的 哪些行正在被执行
,并显示 未使用字节的百分比
, 绿色
的线条表示 已使用内容
, 红
线表示 未使用的内容
:

Changes
检查你修改的内容
2. 在 Chrome 里调 CSS
应该是我工作的日常了,但我总是想将 新写的样式
与 最初样式
进行比较,看看到底有什么不一样,这时候就可以使用 Drawer
的 Changes
:

source
3. 拿到 与 drawer console
一样,当我要专注于 Elements
面板时,有时我也想看源代码,这时就可以在 drawer
中选择显示 Source
。

没有 “主”Source
面板的花里胡哨的功能,没有 call stack
或者 control
( pause
, step over
, 等等)按钮。但如果是 快速查看代码
,或者 设置断点
,它非常有用。
💡
敲黑板 触发的断点不会显示在 Quick sources
中,而是显示在主 Source
中。
Network conditions
模拟网络状态
4. 想测试页面资源的大小,或者测试应用的离线功能? 使用 Drawer
里的 Network conditions
面板模拟特定的网络行为:模拟互联网为典型的3G网络甚至离线!
除此之外, Network conditions
面板还可以自定义网络状态:

Related series
00-写在前面
March 2, 2021
01-Chrome 版本
March 2, 2021
02-复制 & 保存
March 2, 2021
03-快捷键和通用技巧
March 2, 2021
04-使用 Command
March 2, 2021
05-代码块的使用
March 2, 2021
06-console 中的 $
March 2, 2021
07-console.log 的 "bug" ?
March 2, 2021
08-异步的 console
March 2, 2021
09-Ninja console.log
March 2, 2021
10-自定义格式转换器
March 2, 2021
11-对象&方法
March 2, 2021
12-console.log 并不简单
March 2, 2021
13-打造一个终极 log
March 2, 2021
14-打印时间戳
March 2, 2021
15-直接把 `log` 作为回调函数
March 2, 2021
16-初窥 Network
March 2, 2021
17-Network 深入
March 2, 2021
18-Network 细节
March 2, 2021
19-元素面板的基本操作
March 2, 2021
20-元素面板调试技巧
March 2, 2021
21-元素面板里的编辑器
March 2, 2021
22-颜色选择器
March 2, 2021
23-Drawer 使用技巧
March 2, 2021
24-Drawer 动画调试
March 2, 2021
25-Drawer 性能优化
March 2, 2021
26-Workspace 使用技巧
March 2, 2021
27-自动美化输出
March 2, 2021
28-CSS 概览
March 2, 2021
29-Custom UI Themes
March 2, 2021
30-Source diff
March 2, 2021