Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
Transcript
20 slides
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
More Decks by ningzbruc
See All by ningzbruc
如何写出一个优秀的开源库
ningzbruc
0
71
去啊无线前端的一天
ningzbruc
1
220
React & Component
ningzbruc
0
75
阿里旅行去啊H5首页总结&Promise
ningzbruc
0
290
KISSY.Base - all about that Base
ningzbruc
0
150
Hammer.js
ningzbruc
1
370
淘宝旅行门票iPad版开发
ningzbruc
0
170
Travel on KISSY mini
ningzbruc
0
210
Events
ningzbruc
2
140
Other Decks in Technology
See All in Technology
AIが学べる子供の夏休みの自由研究教材を作ったが空振りだった話
yoshimura_datam
0
110
統制されたID・権限をどう利用するか : DPoP/FAPIによるAPIセキュリティ強化
oidfj
2
330
From vibe coding to reliable (agentic) development
jcabot
0
280
PR 生成AIガバナンスの全体像がわかる本
yoshimura_datam
0
110
エンタープライズIAMについて - ID・権限をどう統制するか
oidfj
1
350
AI-Ready なデータ基盤ってなに? & 新卒未経験が、いま考えていること
imuta
0
1.1k
Webメール開発を大幅に変えたJMAPというゲームチェンジャー
tascript
9
5.3k
ワークフローからハーネスへ — Web フレームワークの作者たちが AI エージェントに向かう理由
azukiazusa1
4
3k
フルTypeScript × AI駆動開発で開発量が数倍に (JSConf JP 2026 スポンサーLT:NCDC株式会社)
keitaibaraki
0
330
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.6k
Fukurou Labo_Engineer_Deck
fukuroulabo
0
110
AI-DLCでソフトウェア開発の速さは 上がったのか?
rfdnxbro
0
180
Featured
See All Featured
For a Future-Friendly Web
brad_frost
184
11k
Writing Fast Ruby
sferik
630
63k
Rails Girls Zürich Keynote
gr2m
96
14k
Done Done
chrislema
187
17k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.9k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
640
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1.1k
How Software Deployment tools have changed in the past 20 years
geshan
3
35k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.7k