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.
Size: less than 3.4KB (2KB gzipped) using UglifyJS.
- 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
- IE [tested on v6+]
- FireFox [tested on v2+]
- Chrome [tested on v5+]
- Safari [tested on v4+]
- Opera [tested on v9.6+]
- original document.write function.
- Replaces original
document.write()
with lazy write. - This function will auto executes when "lazywrite.js" loaded.
- To prevent auto executing, sets
AUTO_LAZYWRITE = false;
before loads "lazywrite.js".
- postpones content rendering in the given holder element or current place (like
document.write()
). - An array of all caught exceptions will passes to the
callback()
.
- Starts to render all contents.
- When all content be rendered, it will restores the original
document.write()
.
- Finds and stacks all custom typed script elements.
As AMD Module
- No global variable
LazyWrite
. - no
.prepare()
auto executing.
- Can't use
document.getElement*()
functions to get the writing element in the processing.
<script src="lazywrite-min.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="//pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
setTimeout(LazyWrite.process, 3000); // delay 3sec
</script>