1

I have a bigger webpage and it would take days to add the loading=lazy attribute to all img tags on my site. Is it useful to use something like $('img'). attr('loading', 'lazy') (does this work?) to the site, or will it just make the site more slower?

2
  • YES it works and you can speedup your loading speed. Just check your loading speed by something using like www.gtmetrix.com and then add lazy loader and then check the speed again. Because I do this and its effective Commented Aug 16, 2019 at 5:39
  • Wat type of website are you trying Commented Aug 16, 2019 at 6:53

1 Answer 1

2

It doesn‘t necessarly have the expected effect - if you‘re adding the attributes via JavaScript, the page itself has already been parsed by the browser and their preloading scripts as well and all of those images would be been put to the download queue, as if the attribute wouldn‘t have existed on them.

So I would heavily recommend to add those attributes within the source code itself already.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.