Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
YUI3 DOMReady Bug
Search
ningzbruc
January 24, 2013
Technology
1
100
YUI3 DOMReady Bug
There's a bug in yui3 domready event
ningzbruc
January 24, 2013
Tweet
Share
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
54
去啊无线前端的一天
ningzbruc
1
160
React & Component
ningzbruc
0
38
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
260
KISSY.Base - all about that Base
ningzbruc
0
120
Hammer.js
ningzbruc
1
330
淘宝旅行门票iPad版开发
ningzbruc
0
130
Travel on KISSY mini
ningzbruc
0
190
Events
ningzbruc
2
130
Other Decks in Technology
See All in Technology
今からでも間に合う!速習Devin入門とその活用方法
ismk
1
680
Lambdaの常識はどう変わる?!re:Invent 2025 before after
iwatatomoya
1
480
AI 駆動開発勉強会 フロントエンド支部 #1 w/あずもば
1ftseabass
PRO
0
350
AWS Trainium3 をちょっと身近に感じたい
bigmuramura
1
140
Rubyで楽して タスクを書きたい!
ahogappa
0
110
ChatGPTで論⽂は読めるのか
spatial_ai_network
8
28k
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
280
AWSを使う上で最低限知っておきたいセキュリティ研修を社内で実施した話 ~みんなでやるセキュリティ~
maimyyym
2
400
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
2
240
評価駆動開発で不確実性を制御する - MLflow 3が支えるエージェント開発
databricksjapan
1
160
Reinforcement Fine-tuning 基礎〜実践まで
ch6noota
0
180
regrowth_tokyo_2025_securityagent
hiashisan
0
230
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.4k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Context Engineering - Making Every Token Count
addyosmani
9
510
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
For a Future-Friendly Web
brad_frost
180
10k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
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