Skip to content

zation/LazyWrite

 
 

Repository files navigation

LazyWrite is build to have the best compromise between a good page load and write a complex external data in your page (like Advertising).
This allow you to control when should those data start to render or load.

Advantages
* Increase highly the page load
* Stop freezing client navigator
* Forget iframe calls
* No other library required (like jQuery)
* No(or less) change of existing code

Browser Support:
* IE      [tested on v6+]
* FireFox [tested on v2+]
* Chrome  [tested on v5+]
* Safari  [tested on v4+]
* Opera   [tested on v9.6+]

Demo: http://project.xfsn.net/lazywrite/demo/index.html

Example: Google AdSense
<script src="lazywrite.js"></script>
<script>
    google_ad_client = "ca-pub-5840687392233497";
    google_ad_slot = "9902234827";
    google_ad_width = 728;
    google_ad_height = 90;
    document.write('<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
</script>
<script>$(document).ready(LazyWrite.process); // jQuery</script>

API:
* LazyWrite.write()
  original document.write function.

* LazyWrite.prepare()
  replace original document.write functions by lazy engine.
  run once when the LazyWrite loaded.

* LazyWrite.render(String content, [String holder], [Function callback])
  add content to later render.
  callback function has one parameter: an array of catched exceptions.

* LazyWrite.process()
  start to process the contents.

* LazyWrite.findScripts([String type])
  find and add all custom typed script elements.

About

JavaScript: deferred document.write implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published