Update index.html
Browse files- index.html +16 -7
index.html
CHANGED
|
@@ -1,23 +1,32 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
<html>
|
| 3 |
-
<head><meta charset="utf-8"><title>TF
|
| 4 |
<body>
|
| 5 |
<h3>Transformers.js local load check</h3>
|
| 6 |
<div id="status">Loading…</div>
|
| 7 |
|
| 8 |
-
<!--
|
| 9 |
<script src="./transformers.min.js"></script>
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
const s = document.getElementById('status');
|
| 13 |
try {
|
| 14 |
-
if (
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
} else {
|
| 17 |
-
s.textContent = '
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
} catch (e) {
|
| 20 |
-
s.textContent = '❌
|
| 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>
|