I load lots of Youtube videos in one page (up to 25). Should I use iframe for each video or show it just in <object>
? As I understand, if I use iframe, my page will load much faster, because it will load my page first and it will not have to wait to load videos. Am I right?

- 21,085
- 65
- 193
- 298
-
Opposite question: https://stackoverflow.com/questions/924946/use-of-iframe-or-object-tag-to-embed-web-pages-in-another – Michael Freidgeim Jul 16 '20 at 07:38
2 Answers
Your understanding is incorrect. Your "page" (that is, your HTML document itself) will load and render in the same amount of time. However using <iframes>
means the browser has to load not just the same video files that it would with <object>
, but also the HTML contained within each iframe.
Note that YouTube instructs users to use <iframe>
to embed a video because it allows YouTube to customize the HTML sent to the user: appropriate browsers will be given the HTML5 <video>
treatment.
So it's a trade-off: you can slightly decrease page load times with <object>
or <video>
at the cost of excluding non-Flash (or non-HTML5 browsers, respectively), or you can use <iframe>
and be sure of compatibility with whatever browser your visitors might be using.

- 141,631
- 28
- 261
- 374
-
Accessibility wise though, object tags (from my understanding) are much, much better to have. So that is another consideration as well. – Joel Kinzel Feb 11 '13 at 20:53
You should use <iframe>
since <object>
is deprecated. The first one supports both Flash and HTML5 video. The second one support only Flash. This is extremely useful for users who don't or can't use flash (all of iPad/iPhone users, some of Linux folks).

- 7,416
- 2
- 41
- 58
-
-
@pst, http://support.google.com/youtube/bin/answer.py?hl=en&answer=171780&expand=UseOldEmbedCode#oldcode I mean deprecated for use with YouTube. – Daniil Ryzhkov Sep 23 '12 at 02:56
-