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
YUI3 DOMReady Bug
Search
ningzbruc
January 24, 2013
Technology
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
YUI3 DOMReady Bug
There's a bug in yui3 domready event
ningzbruc
January 24, 2013
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
68
去啊无线前端的一天
ningzbruc
1
200
React & Component
ningzbruc
0
47
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
270
KISSY.Base - all about that Base
ningzbruc
0
140
Hammer.js
ningzbruc
1
340
淘宝旅行门票iPad版开发
ningzbruc
0
140
Travel on KISSY mini
ningzbruc
0
210
Events
ningzbruc
2
130
Other Decks in Technology
See All in Technology
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
1
510
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
500
GoにおけるFFIのこれまでとこれから
goccy
5
3.2k
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
4
1.3k
Minecraft JavaのMODをSwiftで作る
1mash0
0
160
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
HHKBエバンジェリストになる方法
941
0
100
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
1
1.6k
Railsのように考える: See through the Master
snoozer05
PRO
3
740
30座EKS, 180次升級淬煉的EKS Upgrade Skill 的歷程
eric8230
0
150
Screen Lens - 今見てる画面を翻訳する
komagata
0
290
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
12k
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
Raft: Consensus for Rubyists
vanstee
141
7.7k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Automating Front-end Workflow
addyosmani
1369
210k
Optimising Largest Contentful Paint
csswizardry
37
4k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Color Theory Basics | Prateek | Gurzu
gurzu
1
460
Transcript
More Than DOMReady —— yui3 domready bug 1
WTF?! • Request was blocked? • IE was even faster
than Chrome?! • All modules were loaded! 2
domready? Y.on('domready', function() { // more code }); 3
DOMReady • DOMContentLoaded • doScroll • document.readyState 4
DOMContentLoaded document.addEventListener('DOMContentLoaded', function() { fireReady(); }, false); 5
doScroll if (self === self.top) { window.domreadyPoll = setInterval(function() {
try { document.documentElement.doScroll('left'); clearInterval(window.domreadyPoll); window.domreadyPoll = null; fireReady(); } catch (domNotReady) {} }, 10); } 6
document.readyState • loading • interactive • complete 7
document.readyState document.onreadystatechange = function() { if (document.readyState == 'complete') {
fireReady(); document.onreadystatechange = null; } }; 8
fallback window.onload = function() { fireReady(); }; 9
fireOnce • DOMContentLoaded • onload • onreadystatechange (each state) 10
fireOnce window.onload = function() { document.addEventListener('DOMContentLoaded', function(e) { // Oops!
}, false); }; 11
States if (Y.Env.DOMReady) { fireReady(); } if (document.readyState == 'complete')
{ fireReady(); } 12
Non-blocking Script Load • unblock DOMContentLoad • block onload •
block complete readyState 13
What’s the difference? 14
Where Tragedy Happens! DOMContentloaded Slow request Blocked! Event loaded IE
- doScroll onload & domready Endless waiting 15
Solution • contentready • fix it in config file 16
Contentready Y.on('contentready', function() { // more code }, '#content'); 17
Fix it YUI.GlobalConfig = { modules: { // modules config
} }; (function () { var GLOBAL_ENV = YUI.Env; if (!GLOBAL_ENV._ready) { GLOBAL_ENV._ready = function() { GLOBAL_ENV.DOMReady = true; GLOBAL_ENV.remove(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready); }; GLOBAL_ENV.add(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready); } })(); 18
Advice Test More! 19
] { the end. 20