我应该使用< object>或者< iframe>加载视频? [英] Should I use <object> or <iframe> for loading a video?

查看:114
本文介绍了我应该使用< object>或者< iframe>加载视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个页面中加载了大量Youtube视频(最多25个)。我应该为每个视频使用iframe,还是只在< object> 中显示?据我了解,如果我使用iframe,我的页面加载速度会快得多,因为它会首先加载我的页面,而不必等待加载视频。我是对的吗?

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?

推荐答案

您的理解不正确。您的页面(即您的HTML文档本身)将在相同的时间内加载和呈现。但是,使用< iframes> 表示浏览器不仅要加载与< object> ,以及每个iframe中包含的HTML。

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.

请注意,YouTube会指示用户使用< iframe> 嵌入视频,因为它允许YouTube自定义发送给用户的HTML:适当的浏览器将获得HTML5 < video> 处理。

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.

所以这是一个权衡:您可以使用< object> <来略微减少页面加载时间视频> 以分别排除非Flash(或非HTML5浏览器)为代价,或者您可以使用< iframe> 并成为确保与访问者可能使用的任何浏览器兼容。

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.

这篇关于我应该使用&lt; object&gt;或者&lt; iframe&gt;加载视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆