scratch/output/Scratch/en/blog/2009-10-How-to-preload-your-site-with-style/index.html
2012-01-20 11:16:02 +01:00

255 lines
No EOL
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="web, jQuery, webdesign">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/twilight.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Charger une page web avec style" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-How-to-preload-your-site-with-style/" />
<link rel="alternate" lang="en" xml:lang="en" title="How to preload your site with style" type="text/html" hreflang="en" href="/Scratch/en/blog/2009-10-How-to-preload-your-site-with-style/" />
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
<title>How to preload your site with style</title>
</head>
<body lang="en" class="article">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><img src="/Scratch/img/loading.gif" alt="loading..."/></div>');
// ]]>
</script>
<div id="content">
<div id="choix">
<div class="return"><a href="#entete">&darr; Menu &darr;</a></div>
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-How-to-preload-your-site-with-style/" onclick="setLanguage('fr')">en Français</a>
</div>
<div class="flush"></div>
</div>
<div id="titre">
<h1>
How to preload your site with style
</h1>
</div>
<div class="flush"></div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h2 class="first" id="example">Example</h2>
<p>Here is a live example of what appear while loading my pages.</p>
<div id="demo" style="width:45%; position: relative; height: 8em; background: #333; background-position: 50% 50%; color: #fff; text-align: center; padding-top: 1em; margin-left: auto; margin-right: auto; border: solid 10px rgba(255,255,255,0.7); -webkit-border-radius: 1em; -moz-border-radius: 1em; border-radius: 1em; cursor: pointer; ">
<p>Hello! I've finished loading!</p>
<p>Click me to see me disapear again.</p>
<div id="todisapear" style="color: #000; position:absolute;top:0;left:0;text-align: center; padding-top: 1em; width: 100%; background-color: #eee; height: 8em;">
Loading...
<img style="border: none; background-color: none; background: none" src="/Scratch/img/loading.gif" alt="loading logo" />
</div>
<script>
function Rabbit(){
$('#todisapear')
.show()
.animate({opacity: 1.0},3000)
.fadeOut();
}
$(document).ready(function(){
$('#todisapear').animate({opacity: 1.0},3000).fadeOut();
$('#demo').click(Rabbit);
});
</script>
</div>
<p>I first tried to integrate <a href="http://www.gayadesign.com/diy/queryloader-preload-your-website-in-style/">queryLoader</a>, but it didnt fill my needs.</p>
<p>The plugin add a black div to hide all the content. But as the script had to be launched at the end of the source code my website show for a small time.</p>
<p>In order to hide this small artefact, here is how I do that.</p>
<h2 id="code">Code</h2>
<p>In a first time, I added at the top of the body the div hiding all the content.</p>
<div>
<pre class="twilight">
...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">blackpage</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;</span></span>
content to display during the loading.
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span>
...
</pre>
</div>
<p>and here is the associated CSS to <code>#blackpage</code>: </p>
<div>
<pre class="twilight">
<span class="CssId"><span class="CssId">#</span>blackpage</span>
top: 0
left: 0
width: 100%
height: 100%
margin-left: 0
margin-right: 0
margin-top: 0
margin-bottom: 0
position: absolute
text-align: center
color: #666
padding-top: 10em
background-color: <span class="CssId"><span class="CssId">#</span>eee</span>
z-index: 9000
</pre>
</div>
<p>and the associated jQuery code: </p>
<div>
<pre class="twilight">
<span class="Keyword">$</span>(<span class="Support">document</span>).ready(<span class="Storage">function</span>(){
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#blackpage<span class="String">'</span></span>).fadeOut();
});
</pre>
</div>
<p>Yes, it is as simple as that. And, putting the <code>#blackpage</code> div at the top of my page, I ensure to hide anything while loading.</p>
<p>I hope it had helped you!</p>
</div>
<div id="choixrss">
<a id="rss" href="http://feeds.feedburner.com/yannespositocomen">
Subscribe
</a>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#comment').hide();
$('#clickcomment').click(showComments);
});
function showComments() {
$('#comment').show();
$('#clickcomment').fadeOut();
}
document.write('<div id="clickcomment">Comments</div>');
</script>
<div class="flush"></div>
<div class="corps" id="comment">
<h2 class="first">comments</h2>
<noscript>
You must enable javascript to comment.
</noscript>
<script type="text/javascript">
var idcomments_acct = 'a307f0044511ff1b5cfca573fc0a52e7';
var idcomments_post_id = '/Scratch/en/blog/2009-10-How-to-preload-your-site-with-style/';
var idcomments_post_url = 'http://yannesposito.com/Scratch/en/blog/2009-10-How-to-preload-your-site-with-style/';
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type='text/javascript' src='/Scratch/js/genericCommentWrapperV2.js'></script>
</div>
<div id="entete" class="corps_spaced">
<div id="liens">
<ul><li><a href="/Scratch/en/">Home</a></li>
<li><a href="/Scratch/en/blog/">Blog</a></li>
<li><a href="/Scratch/en/softwares/">Softwares</a></li>
<li><a href="/Scratch/en/about/">About</a></li></ul>
</div>
<div class="flush"></div>
<hr/>
<div id="next_before_articles">
<div id="previous_articles">
previous entries
<div class="previous_article">
<a href="/Scratch/en/blog/2009-09-Disqus-versus-Intense-Debate--Why-I-switched-/"><span class="nicer">«</span>&nbsp;Disqus versus Intense Debate (Why I switched)</a>
</div>
<div class="previous_article">
<a href="/Scratch/en/blog/2009-09-jQuery-Tag-Cloud/"><span class="nicer">«</span>&nbsp;jQuery Tag Cloud</a>
</div>
<div class="previous_article">
<a href="/Scratch/en/blog/2009-09-replace-all-except-some-part/"><span class="nicer">«</span>&nbsp;replace all except some part</a>
</div>
</div>
<div id="next_articles">
next entries
<div class="next_article">
<a href="/Scratch/en/blog/2009-10-untaught-git-usage/">Untaught Git usage&nbsp;<span class="nicer">»</span></a>
</div>
<div class="next_article">
<a href="/Scratch/en/blog/2009-10-Focus-vs-Minimalism/">Focus &gt; Minimalism&nbsp;<span class="nicer">»</span></a>
</div>
<div class="next_article">
<a href="/Scratch/en/blog/2009-10-launch-daemon-from-command-line/">launch daemon from command line&nbsp;<span class="nicer">»</span></a>
</div>
</div>
<div class="flush"></div>
</div>
</div>
<div id="bottom">
<div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Copyright ©, Yann Esposito</a>
</div>
<div id="lastmod">
Created: 10/03/2009
Modified: 04/20/2011
</div>
<div>
Entirely done with
<a href="http://www.vim.org">Vim</a>
and
<a href="http://nanoc.stoneship.org">nanoc</a>
</div>
<div>
<a href="/Scratch/en/validation/">Validation</a>
<a href="http://validator.w3.org/check?uri=referer"> [xhtml] </a>
.
<a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3"> [css] </a>
.
<a href="http://validator.w3.org/feed/check.cgi?url=http%3A//yannesposito.com/Scratch/en/blog/feed/feed.xml">[rss]</a>
</div>
</div>
<div class="clear"></div>
</div>
</body>
</html>