Javedalam commited on
Commit
4059173
·
verified ·
1 Parent(s): ecb4204

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +16 -7
index.html CHANGED
@@ -1,23 +1,32 @@
1
  <!doctype html>
2
  <html>
3
- <head><meta charset="utf-8"><title>TF UMD sanity check</title></head>
4
  <body>
5
  <h3>Transformers.js local load check</h3>
6
  <div id="status">Loading…</div>
7
 
8
- <!-- must be in the SAME folder as this index.html -->
9
  <script src="./transformers.min.js"></script>
10
 
11
- <script>
 
12
  const s = document.getElementById('status');
13
  try {
14
- if (window.transformers && window.transformers.pipeline) {
15
- s.textContent = '✅ Loaded OK: window.transformers is present.';
 
 
 
 
16
  } else {
17
- s.textContent = ' Script loaded but window.transformers is missing.';
 
 
 
 
18
  }
19
  } catch (e) {
20
- s.textContent = '❌ Exception after load. See console.';
21
  console.error(e);
22
  }
23
  </script>
 
1
  <!doctype html>
2
  <html>
3
+ <head><meta charset="utf-8"><title>TF load check</title></head>
4
  <body>
5
  <h3>Transformers.js local load check</h3>
6
  <div id="status">Loading…</div>
7
 
8
+ <!-- Try UMD first -->
9
  <script src="./transformers.min.js"></script>
10
 
11
+ <!-- If UMD didn't define a global, import as ESM and assign it -->
12
+ <script type="module">
13
  const s = document.getElementById('status');
14
  try {
15
+ if (!('transformers' in window)) {
16
+ // ESM fallback
17
+ const mod = await import('./transformers.min.js');
18
+ // expose as global so the rest of the app can use window.transformers
19
+ window.transformers = mod;
20
+ s.textContent = '✅ Loaded via ESM import (no UMD global present).';
21
  } else {
22
+ s.textContent = ' Loaded via UMD global (window.transformers present).';
23
+ }
24
+ // quick smoke test
25
+ if (!window.transformers?.pipeline) {
26
+ s.textContent = '⚠️ Library present but pipeline() missing.';
27
  }
28
  } catch (e) {
29
+ s.textContent = '❌ Import failed. See console.';
30
  console.error(e);
31
  }
32
  </script>