Make youtube video look like a gif

Sometimes I need to insert youtube video looped, without sound and without controls, basically it should work like a gif. I’ve tried imgur video to gif, but it limited to 15 seconds video and a bit buggy (need to use http link instead of https).

And I thought that it would be easier to just insert youtube player without controls and info, and use IFrame API for looping (loop param works only with flash player) and muting.

So we need to insert IFrame API script and our script:

<script src="//"></script>
    function onYouTubeIframeAPIReady() {  // called automatically when IFrame API loaded
        []'.gifify'), function(el) {
            var player = new YT.Player(el, {
                events: {
                    'onReady': function() {
                    'onStateChange': function(state) {
                        if ( === 0) {  // video ended
                            player.seekTo({seconds: 0});

And then insert video with ?enablejsapi=1&showinfo=0&controls=0 params and gifify class, like:

<iframe class="gifify" src="" frameborder="0"></iframe>

In action:

comments powered by Disqus