删除移动用户的html5视频背景的最佳方法是什么? [英] What is the best way to remove html5 video background for mobile users
问题描述
解释:我的一位客户希望在他的响应式网站上运行背景视频。但是,他也希望将其移除给平板电脑/移动用户。我知道这可以通过媒体查询完成,但视频仍然会作为DOM的一部分加载,这就是我想要阻止的。
EXPLANATION: A customer of mine wants to have a background video running on his responsive website. However he would also like to remove it for tablet/mobile users. I know this can be done with media queries, but the video would still load as part of the DOM and that is what i would like to prevent.
问题:
-
可以使用JavaScript删除视频元素吗? / jQuery在加载某个宽度的视口时来自DOM?
Can the video element be removed using JavaScript/jQuery from the DOM when it loads view-port at certain widths?
如果手动增加视图端口,可以恢复相同的视频吗? (我怀疑这是一个不好的方法)
Can the same video be recovered when if the view port is manually increased in with? (i suspect this is a bad approach)
视频会显示display:none;仍会影响平板电脑/手机的加载/电池续航时间吗?
Will a video with "display:none;" still affect loading/battery time on a tablet/mobile ?
感谢您的协助。
推荐答案
根据移动维度,使用 $('video')。remove()
。这将从网页中删除DOM元素。所以它不会在html中呈现。
Based on mobile dimensions use $('video').remove()
. this will removes the DOM element from webpage. so it will not render in html.
这篇关于删除移动用户的html5视频背景的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!