File size: 5,275 Bytes
1d3f990 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | # WebLLM CDN Loading Test Guide
## Quick Diagnostic (Copy-Paste to Browser Console)
### Test 1: Check if WebLLM is loaded
```javascript
console.log('window.webllm:', typeof window.webllm);
console.log('window.webllmReady:', window.webllmReady);
console.log('window.webllmError:', window.webllmError);
console.log('window.webllmCDNLoading:', window.webllmCDNLoading);
```
**Expected Output:**
- `window.webllm: object` (if loaded)
- `window.webllmReady: true` (if successfully loaded)
- `window.webllmError: null` (if no error)
- `window.webllmCDNLoading: false` (if CDN finished loading)
### Test 2: Check MLCEngine availability
```javascript
if (window.webllm && window.webllm.MLCEngine) {
console.log('MLCEngine is available');
console.log('typeof MLCEngine:', typeof window.webllm.MLCEngine);
} else {
console.log('MLCEngine not found');
}
```
### Test 3: Check Network Requests
```javascript
// Open DevTools > Network tab, then run:
console.log('Check Network tab for:');
console.log('1. https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.32/dist/web-llm.js');
console.log('2. Should be status 200 (success)');
```
### Test 4: Manual CDN Test (if automatic fails)
```javascript
// Manually load from fallback
const script = document.createElement('script');
script.src = 'https://unpkg.com/@mlc-ai/web-llm@0.2.32/dist/web-llm.js';
script.onload = function() { console.log('unpkg load SUCCESS'); };
script.onerror = function() { console.log('unpkg load FAILED'); };
document.head.appendChild(script);
```
---
## Troubleshooting Flowchart
```
Open https://snapkittywest.github.io/rowm-polymorphic-notebook/index-app.html
Press F12 to open DevTools Console
Paste: console.log(typeof window.webllm)
ββ Shows "object"
β ββ WebLLM loaded successfully β
β Go to step: Load Model Test
β
ββ Shows "undefined"
β ββ Check Network tab for CDN request
β β
β ββ Status 200 (loaded but not ready)
β β ββ Wait 5-10 seconds, refresh page
β β Paste: window.webllm ? 'Loaded' : 'Still failing'
β β
β ββ Status 404 (not found)
β β ββ CDN URL is broken
β β Use fallback: https://unpkg.com/@mlc-ai/web-llm@0.2.32/dist/web-llm.js
β β
β ββ Status CORS error
β β ββ Cross-Origin Request Blocked
β β Try from different browser or clear cookies
β β
β ββ No request at all
β β ββ JavaScript isn't running
β β Check if index-app.html is accessible
β β Try hard refresh: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
β β
β ββ Timeout / No response
β ββ Network issue or CDN down
β Try unpkg fallback (see Test 4 above)
```
---
## Load Model Test
Once WebLLM is confirmed loaded (`window.webllm !== undefined`):
```javascript
// Paste in console:
document.getElementById('ahmad-jit-load').click();
```
Watch the Ahmad Bot box:
- Button text changes to "LOADING" β
- System messages appear with progress
- Model downloads (takes 1-5 minutes)
- Status changes to "READY" when complete
- Send button enables
---
## What Was Fixed (July 27, 2026)
1. **Primary CDN** (jsDelivr) with proper onload/onerror handlers
2. **Fallback CDN** (unpkg) automatically triggered if primary fails
3. **Status tracking** variables: `window.webllmReady`, `window.webllmError`, `window.webllmCDNLoading`
4. **Error messages** in Ahmad Bot chat if CDN fails
5. **Console logging** to help diagnose issues
6. **Library check** in loadModel() - won't try if WebLLM not present
7. **Detailed error info** including CDN error reason
---
## CDNs Used
| CDN | URL | Status |
|-----|-----|--------|
| **Primary** | cdn.jsdelivr.net | Fast, reliable, cached |
| **Fallback** | unpkg.com | Always available, slower |
Both serve the exact same file: `@mlc-ai/web-llm@0.2.32/dist/web-llm.js`
---
## Files Changed
1. **index-app.html** β Added dual CDN loader with fallback
2. **js/ahmad-jit-ui.js** β Added WebLLM availability check before loading model
3. **js/ahmad-jit-engine.js** β Improved error messages with CDN status info
---
## Manual Testing Checklist
- [ ] Open page, check console: `typeof window.webllm` = "object"
- [ ] Check Network tab: CDN request returns 200
- [ ] Click "LOAD LOCAL MODEL" button
- [ ] See system messages appear
- [ ] Model download starts (progress visible in console)
- [ ] After 1-5 minutes, status changes to "READY"
- [ ] Try sending a message
- [ ] Response streams in real-time
---
## Still Having Issues?
1. **Check internet:** Open any website to confirm connection works
2. **Try different browser:** Chrome, Firefox, Safari, Edge
3. **Clear cache:** DevTools > Settings > Network > Uncheck "Disable cache"
4. **Try unpkg directly:** Manually paste Test 4 code above
5. **Check CSP:** Open DevTools, look for Content Security Policy errors
6. **Try private/incognito:** Rules out browser extensions
7. **Check proxy/firewall:** Corporate networks may block CDNs
---
**Report generated:** July 27, 2026
**Page:** https://snapkittywest.github.io/rowm-polymorphic-notebook/index-app.html
|