假设我创建了一个视频并像这样播放:
async function createVideo() {
const videoEl = document.createElement("video");
videoEl.autoplay = true;
videoEl.src = "https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4";
await videoEl.play()
return videoEl
}
createVideo()
.then(() => console.log('video is playing'))
.catch(error => console.log(error))
Run Code Online (Sandbox Code Playgroud)
在 chrome 上,这会导致视频播放,除非元素实际存在于 DOM 中。
该视频将在什么时候被垃圾收集?
此外,如果在返回视频元素之前createVideo()运行video.pause()在内部,垃圾收集将如何工作?视频元素会永远像僵尸一样存在吗?