|
50 | 50 | <a href="" class="reload">Reload</a>
|
51 | 51 | <a class="dismiss">🗙</a>
|
52 | 52 | </div>
|
53 |
| - |
| 53 | + <script src="decode.js"></script> |
54 | 54 | <script src="_framework/blazor.webassembly.js" autostart="false"></script>
|
55 | 55 | <script>
|
56 | 56 | Blazor.start({
|
57 | 57 | loadBootResource: function (type, name, defaultUri, integrity) {
|
58 |
| - // For framework resources, use the precompressed .gz files for faster downloads |
59 |
| - // This is needed only because GitHub pages doesn't natively support response compression for .dll files |
60 |
| - if (type === 'assembly') { |
| 58 | + // For framework resources, use the precompressed .br files for faster downloads |
| 59 | + // This is needed only because GitHub pages doesn't natively support Brotli (or even gzip for .dll files) |
| 60 | + if (type !== 'dotnetjs' && location.hostname !== 'localhost') { |
61 | 61 | return (async function () {
|
62 |
| - const response = await fetch(defaultUri + '.gz', { cache: 'no-cache' }); |
63 |
| - const originalResponseBlob = await response.blob(); |
64 |
| - const decompressedStream = originalResponseBlob.stream().pipeThrough(new DecompressionStream('gzip')); |
65 |
| - return new Response(decompressedStream, { headers: response.headers }); |
| 62 | + const response = await fetch(defaultUri + '.br', { cache: 'no-cache' }); |
| 63 | + if (!response.ok) { |
| 64 | + throw new Error(response.statusText); |
| 65 | + } |
| 66 | + const originalResponseBuffer = await response.arrayBuffer(); |
| 67 | + const originalResponseArray = new Int8Array(originalResponseBuffer); |
| 68 | + const decompressedResponseArray = BrotliDecode(originalResponseArray); |
| 69 | + const contentType = type === 'dotnetwasm' ? 'application/wasm' : 'application/octet-stream'; |
| 70 | + return new Response(decompressedResponseArray, { headers: { 'content-type': contentType } }); |
66 | 71 | })();
|
67 | 72 | }
|
68 | 73 | }
|
|
0 commit comments