shinsenter / defer.js

🥇 A lightweight JavaScript library that helps you lazy load (almost) anything. Defer.js is dependency-free, highly efficient, and optimized for Web Vitals.
https://shinsenter.github.io/defer.js/
MIT License
277 stars 45 forks source link

code inside load function, not execute #100

Closed amit-mall closed 2 years ago

amit-mall commented 2 years ago

code inside load function is not being execute. jQuery(window).on('load', function() { //not executing }) window.addEventListener('DOMContentLoaded', (event) => { //not executing }) window.addEventListener("load", function(){ //not executing }) document.onload = function(){ //not executing })

while .ready is working

shinsenter commented 2 years ago

@amit-mall All the methods you mentioned can be used to lazyload javascript so there is no need to call it inside the Defer() function.

amit-mall commented 2 years ago

Thanks for the response, It means code inside deferred script only executes, after page loads just like code inside $(window).load executes?

shinsenter commented 2 years ago

@amit-mall Basically you can replace the methods mentioned above with the Defer() function, to lazyload the javascript inside. Defer() improves your website load speed as well as improves SEO scores of Google Search's evaluation for your website.

amit-mall commented 2 years ago

ok, thanks