Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Mobile H5 性能优化
Search
ningzbruc
July 09, 2013
Programming
1k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Mobile H5 性能优化
Mobile Performance Optimization
ningzbruc
July 09, 2013
Transcript
58 slides
Mobile H5性能优化 淘宝航旅⽆无线前端⼩小组
Mobile H5性能优化 淘宝航旅⽆无线前端⼩小组
Why • 蜗⽜牛的⺴⽹网速 • 可怜的内存
⺴⽹网络分布
2012全国运营商3G⺴⽹网速对⽐比
https://speakerdeck.com/d2forum/ding-zhi-ban-she-ji-kai-fa-vsxiang-ying-shi-she-ji- kai-fa-zhi-xing-neng-ji-liu-liang
None
None
性能优化⺫⽬目标 更⼩小 + 更快
None
None
None
怎么做
Everything you’ve learned still applies 学到的知识不会过时 怎么做
⽂文件加载 • 减少请求(combo, css-sprites) • ⽆无阻塞加载(异步js,css加载) • ⽼老⽣生常谈...
http://mobitest.akamai.com/m/index.cgi
未优化前
combo+异步后
combo+异步后
combo+异步后 样式表阻⽌止脚本执⾏行!!!
样式表放在head最后⾯面
图⽚片优化
图⽚片优化 552.4K!!!
Data URI
Data URI
Data URI 1920.6K!!!
Data URI • 减少图像HTTP请求 • 体积增⼤大(约30%,gzip后约10%) • 不能被缓存
最佳实践 体积较⼩小并且重复率低的图⽚片使⽤用Data URI进⾏行 编码,⽐比如⼩小icon等
图⽚片压缩 http://tinypng.org/
图⽚片压缩
图⽚片压缩 210.9K!!!
压缩⼯工具 http://tinypng.org/ imageAlpha imageOptim JPEGmini
压缩⼯工具 http://tinypng.org/ imageAlpha imageOptim JPEGmini $ npm install -g imageoptim-cli
$ imageOptim -j -a -q -d path/to/images
代码瘦⾝身 http://a.tbcdn.cn/mw/base/styles/tms_h5.css
代码瘦⾝身 http://a.tbcdn.cn/mw/base/styles/tms_h5.css
None
None
我们需要优化代码
CSS优化 • 选择器优化 • 不要滥⽤用CSS3特性 • “position:fixed” • repaint &
reflow • ...
选择器优化 https://speakerdeck.com/jonrohan/githubs-css-performance https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Writing_efficient_CSS
不要滥⽤用特性 • box-shadow/text-shadow • transition/transform • background: gradient(...) • ...
滥⽤用CSS3特性会导致⻚页⾯面渲染变慢,滚动效果卡顿(⽐比如说...⼩小⽶米2)
不要滥⽤用特性 • box-shadow/text-shadow • transition/transform • background: gradient(...) • ...
滥⽤用CSS3特性会导致⻚页⾯面渲染变慢,滚动效果卡顿(⽐比如说...⼩小⽶米2)
不⽀支持position:fixed?
不⽀支持position:fixed?
position:fixed http://bradfrostweb.com/blog/post/mobile-web-problems/#fixed
慎⽤用position:fixed • 部分低版本系统不⽀支持 • 可视范围更⼩小 • html:100%+absolute+iscroll,代码量增加
js优化 • 尽量⽤用原⽣生代码 • DOM选择器性能优化 • DOM节点缓存 • 注意内存释放 •
...
尽量⽤用原⽣生代码 https://speakerdeck.com/yaypie/when-not-to-use-yui var myObj = {}; var myObj = Y.Base.create(...);
尽量⽤用原⽣生代码 https://speakerdeck.com/yaypie/when-not-to-use-yui var myObj = {}; var myObj = Y.Base.create(...);
https://speakerdeck.com/lijing00333/css-selector-performance
更多 • ⺴⽹网络监控 • 缓存 • 统计
⺴⽹网络监控 2G/3G/4G/Wifi?
缓存 • APP存在缓存问题 • APP退出之后清空缓存
统计 • 优化需要更多的数据统计⽀支持 • CNZZ,⾕谷歌分析,淘宝⽆无线指数
总结 如何做好⽆无线端的性能优化?
总结 • 不留余地 • 绞尽脑汁 • 鸡蛋挑⾻骨头 • 不择⼿手段 •
令⼈人发指 • 测试,测试,测试... • ...
to be continued.. 开发调试篇
The End.
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
71
去啊无线前端的一天
ningzbruc
1
220
React & Component
ningzbruc
0
75
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
290
KISSY.Base - all about that Base
ningzbruc
0
150
Hammer.js
ningzbruc
1
370
淘宝旅行门票iPad版开发
ningzbruc
0
170
Travel on KISSY mini
ningzbruc
0
210
Events
ningzbruc
2
140
Other Decks in Programming
See All in Programming
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
710
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
670
ruby/uri meets WHATWG
jinroq
0
160
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
230
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
210
Getting Started with Vibe Coding
miccheng
0
250
Crash Auto Pipelines
veronikapj
1
450
Proxmox x Talos Linux x Terraform で実現するなんかいい感じの Kubernetes クラスタ / A Sleek Kubernetes Cluster Powered by Proxmox, Talos Linux, and Terraform
nnaka2992
0
320
AppFunctionsの内部実装を紐解く
hiroaki404
1
120
数行の変更でDockerビルドを最大91%高速化~GitLab CIの実行基盤を社内40リポジトリに展開するまで~
picopico
3
1k
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
230
Featured
See All Featured
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
760
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k
Skip the Path - Find Your Career Trail
mkilby
1
300
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
Prompt Engineering for Job Search
mfonobong
0
610
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Amusing Abliteration
ianozsvald
1
400
How to Think Like a Performance Engineer
csswizardry
28
3k
Well, that’s weird…
csswizardry
3
240
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k