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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
190
React & Component
ningzbruc
0
45
阿里旅行去啊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
信頼性はSREだけのものじゃない
hkawaras
0
150
Dylib Hijacking on macOS: Dead or Alive?
patrickwardle
0
110
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
20k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
77k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.5k
Windows の互換機能 - 古いプログラムはなぜ動作できるのか
murachiakira
PRO
0
110
型落ちシンクライアント端末のPoEモジュールを自作したかった話
logica0419
0
460
AI時代の「OAuth認証」にどう物申すか?(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
300
Digital Credentials API × OpenID4VP ブラウザ完結型本人確認の実装知見(OAuth/OIDC Numa (Immersion) Workshop 2026)
oidfj
PRO
0
290
医療の現場を変革に挑戦した半年間の軌跡 - PythonとAIで現場を変える / From Code to Care
soudai
PRO
1
630
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.2k
Microsoft MVP プログラムを紹介するから目指す人増えてくれ
tsubakimoto_s
0
120
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
ラッコキーワード サービス紹介資料
rakko
1
4.5M
Raft: Consensus for Rubyists
vanstee
141
7.7k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
490
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
My Coaching Mixtape
mlcsv
0
290
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Writing Fast Ruby
sferik
630
63k
We Have a Design System, Now What?
morganepeng
55
8.3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
510
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