Answer a more specific question:
Don't you really need a plugin? Just do something in that direction.
This will call the postponedHeavyFunction() function only after the user clicks on the element with id lazyelement and only once.
function postponedHeavyFunction() {
Check out http://jsbin.com/agora/ for a deadly silly demo.
What exactly do you want. What should be lazy loaded / lazy? Be more specific.
Lazy evaluation (as is known from other languages) AFAIK is not supported in Javascript per se (as a language concept). Except, perhaps, for operators such as & , | , && , || .
If you just want some javascript to be lazy to load other scripts, take a look at this: Riskless lazy JavaScript loading with LazyLoad
source share