Skip to content

Instantly share code, notes, and snippets.

@kvzhuang
Created October 30, 2012 08:51
Show Gist options
  • Save kvzhuang/3979089 to your computer and use it in GitHub Desktop.
Save kvzhuang/3979089 to your computer and use it in GitHub Desktop.
image preload test1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="">
<meta name="created" content="2012-10-30">
<title> Prototype</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssreset/reset-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssfonts/fonts-min.css">
<script type="text/javascript" src="http://yui.yahooapis.com/3.7.2/build/yui/yui-min.js"></script>
<style type="text/css">
</style>
</head>
<body>
<div class="image" style="display:none">
<img id="image1" src="" width="500" height="500"/>
</div>
<script>
var imageOnload;
YUI().use('node', function (Y) {
var startload = (new Date()).getTime();
Y.log("loading : "+startload);
var img = document.getElementById("image1");
img.src ="http://dl.dropbox.com/u/10258402/logo/%E8%8E%8ALOGO_RGB-01.png";
imageOnload = function () {
Y.one(".image").setStyle("display" , "block");
var afterload = (new Date()).getTime();
Y.log("total : "+(afterload - startload));
};
img.onload = imageOnload;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment