imLazy
is a simple library to let your images lazier, it's a library to do image Lazy Loader, quite simple.
Javascript, it's everything you need.
Download the code and include the file imLazy.js
Include it in your HTML, supposing you have fallowing HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="imLazy.js"></script>
</head>
<body>
<img src="https://placehold.it/350x150?text=your+placehold+image" alt="">
</body>
</html>
Then use it in your Javascript code:
const img = document.querySelector('img');
const imgUrl = 'http://bit.ly/2qgUBr3';
new imLazy(img, imgUrl);
The reason why I did with Javascript Vanilla instead of jQuery
or any other modern framework, is because this way allows me extend it to all of them frameworks quickly.
- Able to required by NodeJS, React, Angular or any other importable framework.