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
770
贡献标准.s01.e02
d2forum
3
1.3k
一淘响应式设计实践
d2forum
10
960
响应式web设计与实现介绍
d2forum
8
800
定制版设计开发vs响应式设计开发
d2forum
0
170
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
KATA
mclloyd
32
14k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
RailsConf 2023
tenderlove
30
1.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Docker and Python
trallard
45
3.5k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Rails Girls Zürich Keynote
gr2m
95
14k
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