Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
淘宝本地生活 Mini Head 实践
Search
d2forum
August 03, 2012
2
130
淘宝本地生活 Mini Head 实践
淘宝公用头脚本比较大,而head中的脚本会阻塞页面渲染,通过mini head来有效解决head过重问题
d2forum
August 03, 2012
Tweet
Share
More Decks by d2forum
See All by d2forum
TMS的PHP特性
d2forum
0
1.6k
Leap Motion体感实战
d2forum
0
1.2k
跨终端产品实践
d2forum
12
1.9k
Touching Future—s01-e01
d2forum
2
900
KissyCake
d2forum
3
760
贡献标准.s01.e02
d2forum
3
1.3k
一淘响应式设计实践
d2forum
10
960
响应式web设计与实现介绍
d2forum
8
790
定制版设计开发vs响应式设计开发
d2forum
0
170
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
24
1.7k
A designer walks into a library…
pauljervisheath
206
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
107
19k
A Tale of Four Properties
chriscoyier
160
23k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Practical Orchestrator
shlominoach
188
11k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
4 Signs Your Business is Dying
shpigford
184
22k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
Building an army of robots
kneath
306
45k
VelocityConf: Rendering Performance Case Studies
addyosmani
330
24k
Transcript
本地生活 Mini 头实践 —— 元晃
OVERVIEW OVERVIEW head 里的 js 头大的问题 解决问题 部署 && 应用
head 里的 js head • 125KB+ • 45KB+ gzip
头大的问题 头大的问题 • 阻塞 ——head 中的脚本会阻塞页面渲染!
头大的问题 头大的问题 <!doctype html> <html> <head> <title>js 阻塞测试 </title> </head>
<body> 主体 </body> </html> <script src="sleep.php?delay=20"></script> 20s
解决问题 解决问题 • 让 head 轻一点 —— 把 head 中的脚本往页面底部挪
解决问题 解决问题 • 但是……
解决问题 HOW? 解决问题 • 作假
解决问题 • 单击此处编辑母版文本样式 – 第二级 – 第三级 • 第四级 –
第五级
解决问题 存储匿名函数
解决问题 • 单击此处编辑母版文本样式 – 第二级 – 第三级 • 第四级 –
第五级 取出匿名函数并执行
• 一个轻量头解决方案 • 只有 50 行左右 • 改造成本低
量化 • HttpWatch • 注意 -HttpWatch 的 clear cache 功能可能有问
题,请用 IE 自带的工具条设置“总是从服务器 更新” Render Start DOM Load Page Load
部署 • 两部分 -mini_core.js 20 行左右,直接写在 head 中 -mini_exe.js 30
行左右 • Source and test code • 本地生活
The End