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.5k
Leap Motion体感实战
d2forum
0
1.2k
跨终端产品实践
d2forum
12
1.9k
Touching Future—s01-e01
d2forum
2
880
KissyCake
d2forum
3
730
贡献标准.s01.e02
d2forum
3
1.3k
一淘响应式设计实践
d2forum
10
950
响应式web设计与实现介绍
d2forum
8
780
定制版设计开发vs响应式设计开发
d2forum
0
160
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Making Projects Easy
brettharned
109
5.5k
Practical Orchestrator
shlominoach
183
9.8k
The Brand Is Dead. Long Live the Brand.
mthomps
49
31k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
Bash Introduction
62gerente
605
210k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
2k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
32
47k
For a Future-Friendly Web
brad_frost
172
9k
Designing with Data
zakiwarfel
96
4.8k
Embracing the Ebb and Flow
colly
80
4.2k
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