Is there a way to load embedded YouTube videos faster on my website?

前端 未结 5 1760
南旧
南旧 2020-12-29 00:19

I\'m writing a blog post that uses multiple videos from YouTube and Yahoo Video, but I\'m not happy with how long it takes the page to render. Apart from using an ajax-y met

5条回答
  •  庸人自扰
    2020-12-29 00:38

    The problem with embedded YouTube videos is that the player itself needs to load. You could add "controls=2" in the URL of the embedding code, but that would make only AS2/3 players to load the player after clicking.

    The workaround Google+ has for this issue is not to load the player at all. Instead, it loads a thumbnail image with a play button superimposed. On clicking, the image is replaced with the actual YouTube player iframe embed code and it loads and auto-plays.

    This can be done in any site actually using the simple javascript below. https://skipser.googlecode.com/files/gplus-youtubeembed.js

提交回复
热议问题