Video Streaming Embed Code

If I have multiple videos embedded on one page, do I need include the .js file more than once?

Each embed code is like this:

<stream src="####" controls></stream>
<script data-cfasync="false" defer type="text/javascript" src=""></script>

But if I have multiple videos, can I not just put the <stream> tag for each video and then only include the <script> once? I might be wrong, but I really do not see anything in the .js file that is using that video query string… and including it more than once might be causing load time and page size issues…

Dunno…give it a try and let us know how it goes. But I bet it breaks. The script includes the stream ID. No script…no play.

The script does include the stream ID, but does not appear to use it…

Which, I just tested this, and it works fine with just calling the script once while having multiple stream elements on one page.

Each video loads as expected.

1 Like

I’m glad I didn’t put any money on that bet. :smile:

In fact, what I did was this:

I only include the stream tag in the HTML where I want to embed the video… and then in the footer of all pages, I have this

(function() {
  if(document.getElementsByTagName("stream").length > 0) {
    var script= document.createElement("script");
    script.type= "text/javascript";
    script.defer = "defer";
    script.src= "";

So if there are any stream tags, it automatically loads the javascript… and if there are none, it does not.

1 Like