How to optimize iframe load time?

Asked

Viewed 893 times

1

I have a page with several "iframes" youtube that are taking considerably to load.

Foto:

I wonder if it is possible to decrease this loading time or if it is not possible, how to put an animation until all videos are loaded.

  • could put part of your code to help

1 answer

4


Yes, it would be possible to decrease the page load time, you should only load what is visible on the screen, the others would leave for later. See if the Lazy load XT plugin in this link helps you:

https://github.com/ressio/lazy-load-xt

About the animation, it is very simple and quick to do, just put an image as background of your iframe through CSS.

http://codepen.io/dudaskank/pen/eBVpKw

CSS

iframe.loading {
  /* imagem from search on google :p */
  background: url(https://www.aiag.org/Content/images/admin_throbber.gif) no-repeat center center;
}

HTML

<iframe class='loading' src='https://www.youtube.com/embed/Zi_XLOBDo_Y' />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.