HTML video tag not showing on source of some websites


Why is it that every time I try to view the source of a website that plays HTML 5 video (like YouTube), I don't see the HTML video tag?

For example, on this site:

Best Answer

You don't see the video tag if you just load the page source on its own. This is because the video DOM element is added to the page dynamically, with JavaScript, and not even persisted in the page source.

Here's the video tag in from your example:

It's inserted through JavaScript inside <div class="html5-remote-module"> after the video metadata and everything else has been loaded. One reason for not "hard-coding" the video tag inside the page is that the link to the video resource has to be present inside the tag (as the src attribute), and YouTube distributes the requests to a large number of caching servers rather than pointing to a single resource.