Skip to content

Commit

Permalink
youtube: Only include CSS for first video
Browse files Browse the repository at this point in the history
This avoids having the CSS in the <head> multiple times. Doesn't happen
right now since we don't have multiple videos on one page.
  • Loading branch information
cdown committed Jan 5, 2022
1 parent b4b90d3 commit b1d689b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions _plugins/youtube.rb
Expand Up @@ -14,11 +14,15 @@ def initialize(tagName, markup, tokens)
def render(context)
%Q{
<script type="text/javascript">
var link = document.createElement("link");
link.href = "/css/lite-yt-embed.css";
link.type = "text/css";
link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link);
var ytcss_id = "ytcss";
if (!document.getElementById(ytcss_id)) {
var link = document.createElement("link");
link.href = "/css/lite-yt-embed.css";
link.id = ytcss_id;
link.type = "text/css";
link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link);
}
</script>
<script src="/js/lite-yt-embed.js"></script>
<lite-youtube videoid="#{@id}" playlabel="Play"></lite-youtube>
Expand Down

0 comments on commit b1d689b

Please sign in to comment.