dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.63k stars 356 forks source link

Lazy loading script-tags #117

Open 9uenther opened 7 years ago

9uenther commented 7 years ago

The changes let me now load script-tags dynamically, when a defined parent element is shown in the viewport. You can also omit the parent id, in that case the real parent is used to load the script.

Following example shows the usage with google-maps:

<div id="map"></div>
<script class="b-lazy" data-parent="map" data-src="https://maps.googleapis.com/maps/api/js?key=mySuperSecretAPIkey&#038;callback=initMap" async defer></script>