File tree Expand file tree Collapse file tree
src/components/wistia-video Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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` } > </ div >
2324 ) ;
You can’t perform that action at this time.
0 commit comments