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
1
95
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
25
去啊无线前端的一天
ningzbruc
1
130
React & Component
ningzbruc
0
14
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
230
KISSY.Base - all about that Base
ningzbruc
0
87
Hammer.js
ningzbruc
1
310
淘宝旅行门票iPad版开发
ningzbruc
0
94
Travel on KISSY mini
ningzbruc
0
160
Events
ningzbruc
2
100
Other Decks in Technology
See All in Technology
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
3
640
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
13k
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
430
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
190
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Application Development WG Intro at AppDeveloperCon
salaboy
0
200
The Rise of LLMOps
asei
9
1.8k
The Role of Developer Relations in AI Product Success.
giftojabu1
0
150
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
940
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
4
240
【LT】ソフトウェア産業は進化しているのか? #Agilejapan
takabow
0
100
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Building Adaptive Systems
keathley
38
2.3k
Writing Fast Ruby
sferik
627
61k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Designing for humans not robots
tammielis
250
25k
Site-Speed That Sticks
csswizardry
0
33
Side Projects
sachag
452
42k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
BBQ
matthewcrist
85
9.3k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Building Applications with DynamoDB
mza
90
6.1k
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