File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 * `obs-speedcurve.js`.
88 */
99
10+ // Immediately disallow the inclusion of Obs.js as an external script—or as an
11+ // inline `type=module`—except on localhost. This file cannot be run
12+ // asynchronously, which means it should not be placed externally either: that
13+ // would kill performance and that’s the exact opposite of what we’re trying
14+ // to achieve.
15+ const obsSrc = document . currentScript ;
16+
17+ if ( ! obsSrc || obsSrc . src || ( obsSrc . type && obsSrc . type . toLowerCase ( ) === 'module' ) ) {
18+ if ( / ^ ( l o c a l h o s t | 1 2 7 \. 0 \. 0 \. 1 ) $ / . test ( location . hostname ) === false ) {
19+ console . warn (
20+ '[obs] Skipping: must be an inline, classic <script> in <head>.' ,
21+ obsSrc ? ( obsSrc . src ? 'src=' + obsSrc . src : 'type=' + obsSrc . type ) : 'type=module'
22+ ) ;
23+ return ;
24+ }
25+ }
26+
1027 // Attach classes to the document.
1128 const html = document . documentElement ;
1229
You can’t perform that action at this time.
0 commit comments