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
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
51
去啊无线前端的一天
ningzbruc
1
160
React & Component
ningzbruc
0
36
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
250
KISSY.Base - all about that Base
ningzbruc
0
110
Hammer.js
ningzbruc
1
330
淘宝旅行门票iPad版开发
ningzbruc
0
120
Travel on KISSY mini
ningzbruc
0
190
Events
ningzbruc
2
120
Other Decks in Technology
See All in Technology
なぜThrottleではなくDebounceだったのか? 700並列リクエストと戦うサーバーサイド実装のすべて
yoshiori
4
1.2k
【Android】テキスト選択色の問題修正で心がけたこと
tonionagauzzi
0
130
CodexでもAgent Skillsを使いたい
gotalab555
9
4.1k
ソフトウェアエンジニアとデータエンジニアの違い・キャリアチェンジ
mtpooh
1
730
ubuntu-latest から ubuntu-slim へ移行しよう!コスト削減うれしい~!
asumikam
0
450
Claude Code 10連ガチャ
uhyo
3
630
「データ無い! 腹立つ! 推論する!」から 「データ無い! 腹立つ! データを作る」へ チームでデータを作り、育てられるようにするまで / How can we create, use, and maintain data ourselves?
moznion
2
600
隙間ツール開発のすすめ / PHP Conference Fukuoka 2025
meihei3
0
260
AWS 環境で GitLab Self-managed を試してみた/aws-gitlab-self-managed
emiki
0
350
内部品質・フロー効率・コミュニケーションコストを悪化させ現場を苦しめかねない16の組織設計アンチパターン[超簡易版] / 16 Organization Design Anti-Patterns for Software Development
mtx2s
2
150
龍昌餃子で理解するWebサーバーの並行処理モデル - 東葛.dev #9
kozy4324
1
140
クレジットカードの不正を防止する技術
yutadayo
7
2.5k
Featured
See All Featured
The Language of Interfaces
destraynor
162
25k
4 Signs Your Business is Dying
shpigford
186
22k
Gamification - CAS2011
davidbonilla
81
5.5k
Building an army of robots
kneath
306
46k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
920
Navigating Team Friction
lara
190
15k
The Pragmatic Product Professional
lauravandoore
36
7k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
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