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
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
66
去啊无线前端的一天
ningzbruc
1
180
React & Component
ningzbruc
0
45
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
270
KISSY.Base - all about that Base
ningzbruc
0
130
Hammer.js
ningzbruc
1
340
淘宝旅行门票iPad版开发
ningzbruc
0
140
Travel on KISSY mini
ningzbruc
0
200
Events
ningzbruc
2
130
Other Decks in Technology
See All in Technology
日本 Fintech 未来予測レポート 2027〜2028年(オリジナル版)
8maki
0
2.2k
Android の公式 Skill / Android skills
yanzm
0
140
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
130
入門!AWS Blocks
ysuzuki
1
120
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
980
NAB Show 2026 動画技術関連レポート / NAB Show 2026 Report
cyberagentdevelopers
PRO
0
200
RAG を使わないという選択肢
tatsutaka
1
230
人材育成分科会.pdf
_awache
4
240
2026 TECHFRESH 畢業分享會 - 開發日常大解密!從領域驅動到企業級上線
line_developers_tw
PRO
0
980
非エンジニアがClaudeと挑んだ「1ヶ月間プロダクト30本ノック」
askokc
0
490
SONiCで構築・運用する生成AI向けパブリッククラウドネットワーク ~実装編~
sonic
0
200
Disciplined Vibes: Scaling AI-Assisted Engineering
sheharyar
0
140
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Why Our Code Smells
bkeepers
PRO
340
58k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
310
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
The Curse of the Amulet
leimatthew05
1
13k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
220
Odyssey Design
rkendrick25
PRO
2
700
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
850
Speed Design
sergeychernyshev
33
1.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