Tuesday, June 15th, 2010
Y.preload: load before execution
<p>Caridy Patino has posted on a new YUI3 module for preloading of content, implementing Stoyan's ideas.You can now strap on some preloading goodness to your YUI application:
-
-
YUI({
-
//Last Gallery Build of this module
-
gallery: 'gallery-2010.05.05-19-39'
-
}).use('gallery-preload', function(Y) {
-
Y.preload ([
-
'http://tools.w3clubs.com/pagr2/1.sleep.expires.png',
-
'http://tools.w3clubs.com/pagr2/1.sleep.expires.js',
-
'http://tools.w3clubs.com/pagr2/1.sleep.expires.css'
-
]);
-
});
-
As well as just loading away, you can also wait for the user to focus on something on the page before reloading:
-
-
Y.on("focus", function() {
-
Y.preload ([
-
'http://tools.w3clubs.com/pagr2/2.sleep.expires.png',
-
'http://tools.w3clubs.com/pagr2/2.sleep.expires.js',
-
'http://tools.w3clubs.com/pagr2/2.sleep.expires.css'
-
]);
-
}, ".myform input.query");
-
Or, to take it even further, only preload if the user is probably idle:
-
-
Y.preloadOnIdle ([
-
'http://tools.w3clubs.com/pagr2/3.sleep.expires.png',
-
'http://tools.w3clubs.com/pagr2/3.sleep.expires.js',
-
'http://tools.w3clubs.com/pagr2/3.sleep.expires.css'
-
], 100); // ms
-
Nicely packaged.
Related Content:











Leave a comment