Skip to content

vladimirdh/Lazy-Load-Images-without-jQuery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Lazy load your images without the overhead of a framework. Optionally, send mobile-optimized images to smaller screens. Tested on IE7+, Firefox, Chrome, Safari, iOS.

Based on code from Mike Pulaski.

Usage

  1. Include lazyload.js or inline it or import or require it.

  2. Add .lazy-load and data-src to each of your <img> tags. Optionally add data-src-mobile, a placeholder src, and a fallback image.

<img class="lazy-load" data-src="lazy.jpg" data-src-mobile="lazy-small.jpg" src="blank.gif" />
<noscript><img src="lazy.jpg" /></noscript>
  1. Add CSS3 magic for an animated fade-in:
.lazy-load, .lazy-loaded {
  -webkit-transition: opacity 0.3s;
  -moz-transition: opacity 0.3s;
  -ms-transition: opacity 0.3s;
  -o-transition: opacity 0.3s;
  transition: opacity 0.3s;
  opacity: 0;
}

.lazy-loaded { opacity: 1; }
  1. Manually run the plugin. If there is any new images you justed appended into the DOM, just run again.
    lazyload.run();

Demo

http://kaizau.github.com/Lazy-Load-Images-without-jQuery/

About

Lazy load your images without the overhead of a library. IE7+, FF, Chrome.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 39.8%
  • HTML 31.5%
  • JavaScript 28.7%