Skip to content

Lazy Element Plugin

Fatih Kadir Akın edited this page Apr 26, 2016 · 3 revisions

Installation

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bricklayer/<version>/bricklayer.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/bricklayer/<version>/bricklayer.min.js"></script>

<!-- You should also add bricklayer.lazyElement.js -->
<script src="//cdnjs.cloudflare.com/ajax/libs/bricklayer/<version>/plugins/lazyElement/bricklayer.lazyElement.min.js"></script>

For advanced installation options plase see installations page.

Note: Lazy Element Plugin doesn't have NPM or Bower installations yet.

Usage

Lazy Element Load is used to add elements lazily.

// Element will append 1s later.
bricklayer.appendLazyElement(function (done) {
  setTimeout(function () {
    done(element)
  }, 1000)
})
// Image will wait source to be loaded to append.
bricklayer.appendLazyElement(function (done) {
  var image = new Image()
  image.src = "demo.jpg"
  image.onload = function () {
    done(image)
  }
})