Defer iframe for your website to make your website loading fast. iframe source loading took some time and which blocks other scripts to load  as quickly as you can. We can defer the iframe so the other scripts can load quickly and our iframe will be loading after page scripts is fully loaded.

This method make the site faster.

This is default iframe user with no defer

How to make defer in ifarame?

Just put the ‘src’  attribute blank and add the source url at  ‘data-src’ attribute.

this is how we will not be loading iframe content during page load time. Now we have an script to replace the data-src attribute to the src attribute value. Put this code in your project.

Thats it.

You can test your website in GTMETRIX

Leave a Reply