Skip to content

Commit 421d720

Browse files
committed
don’t prerender wistia videos
1 parent e438af2 commit 421d720

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎src/components/wistia-video/wistia-video.tsx‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Prop, h } from '@stencil/core';
1+
import { Build, Component, Prop, h } from '@stencil/core';
22

33
@Component({
44
tag: 'wistia-video'
@@ -7,17 +7,18 @@ export class WistiaVideo {
77
@Prop() videoId: string;
88

99
componentDidLoad() {
10-
if (!document.getElementById('wistia_script')) {
11-
const wistiaScript = document.createElement('script');
12-
wistiaScript.id = 'wistia_script';
13-
wistiaScript.type = 'text/javascript';
14-
wistiaScript.src = 'https://fast.wistia.com/assets/external/E-v1.js';
15-
wistiaScript.async = true;
16-
document.body.appendChild(wistiaScript);
17-
}
10+
if (document.getElementById('wistia_script') || !Build.isBrowser) return;
11+
12+
const wistiaScript = document.createElement('script');
13+
wistiaScript.id = 'wistia_script';
14+
wistiaScript.type = 'text/javascript';
15+
wistiaScript.src = 'https://fast.wistia.com/assets/external/E-v1.js';
16+
wistiaScript.async = true;
17+
document.body.appendChild(wistiaScript);
1818
}
1919

2020
render() {
21+
if (!Build.isBrowser) return;
2122
return (
2223
<div class={`wistia_embed wistia_async_${this.videoId} videoFoam=true`}>&nbsp;</div>
2324
);

0 commit comments

Comments
 (0)