Skip to content

Instantly share code, notes, and snippets.

@ingowennemaring
Created April 18, 2013 15:35
Show Gist options
  • Save ingowennemaring/5413702 to your computer and use it in GitHub Desktop.
Save ingowennemaring/5413702 to your computer and use it in GitHub Desktop.
Load a video later via jQuery (incl. fix for webkit)
<video width="300" height="500" poster="poster.jpg">
<source type="video/mp4" src="" data-src="video.mp4" />
<source type="video/webm" src="" data-src="video.webm" />
</video>
$('source[data-src]').each(
function(i) {
var $this = $(this);
// Webkit-Fix
if($.browser.webkit && $this.attr('type') == "video/mp4") {
$this.parent().attr('src', $this.data('src'));
}
$this.attr('src', $this.data('src')).removeAttr('data-src');
$this.parent().get()[0].load();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment