good_evening
good_evening

Reputation: 21749

Should I use <object> or <iframe> for loading a video?

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?

Upvotes: 2

Views: 4113

Answers (2)

Dai
Dai

Reputation: 155270

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.

Upvotes: 6

Daniil Ryzhkov
Daniil Ryzhkov

Reputation: 7596

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).

Google Help on this question

Upvotes: 0

Related Questions