Created
June 28, 2015 22:49
-
-
Save hiwelo/87d1633389648f6b00f6 to your computer and use it in GitHub Desktop.
Snippet d'explication du principe de lazyload du background CSS différencié de l'image principale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Avant le chargement du JS --> | |
<section data-background-url="URL_TO_BKGND"><!-- Ici le pattern de fond du bloc, qui sera intégré après le chargement du HTML & CSS sous la forme d'un style inline via JS --> | |
<img src="data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=" data-src="URL_TO_HUMAN" alt=""> | |
<noscript> | |
<img src="URL_TO_HUMAN" alt="A117_ALT_TEXT"> | |
</noscript> | |
<h*></h*><!-- Titre de la section, si nécessaire --> | |
<p></p><!-- Contenu de la section --> | |
</section><!-- ./section --> | |
<!-- Après le chargement du JS --> | |
<section style="background-image: url('URL_TO_BKGND');"><!-- Le background chargé en inline --> | |
<img src="URL_TO_HUMAN" alt="A117_ALT_TEXT"><!-- L'image ajoutée via JS depuis les données data- --> | |
<noscript> | |
<img src="URL_TO_HUMAN" alt="A117_ALT_TEXT"> | |
</noscript> | |
<h*></h*><!-- Titre de la section, si nécessaire --> | |
<p></p><!-- Contenu de la section --> | |
</section><!-- ./section --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment