@blinkk/degu
    Preparing search index...

    Function flushVideos

    • Flushes all video sources in a given element. This allow the VRAM to flush. Use unflushVideos to put it back.

      This is particularly useful to combine with inview. Where normally, it would take Chrome a couple of seconds to flush memory of an outview video, this would do it explicitly release memory much quicker.

      Current will only work with video with not video with src.

       <video>
      <source src="xxx.mp4"></source>
      <source src="xxx.webm"></source>
      </video>

      Basically, this works by removig the src attribute from each video and then force reloading it - flushing it from memory.

         let ev = elementVisibility.inview(
      el, {rootMargin: '100px 100px 100px 100px'}, () => {
      if (ev.state().ready) {
      if (ev.state().inview) {
      dom.unflushVideos(el);
      } else {
      dom.flushVideos(el);
      }
      }
      });

      You may also have a case where you are lazyloading videos as such:

      <video>
      <source lazyvideo-src="xxx.mp4"></source>
      </video>

      In this case, you can use the source attribute to specify the data-attritube that contains the path to the source.

          dom.flushVideos(el, 'lazyvideo-src');
      

      https://html.spec.whatwg.org/multipage/media.html#best-practices-for-authors-using-media-elements

      Parameters

      • el: HTMLElement

        The html element to search

      • sourceAttribute: string = ''

        An optional attribute value to acquire the video source from.

      Returns void