Skip to content

Commit

Permalink
Better names, fix bug loading CDN
Browse files Browse the repository at this point in the history
  • Loading branch information
sidoh committed Oct 19, 2024
1 parent 7e3c64f commit dfbb2d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions web2/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ function generateGzippedHeader(inputFile, variableName) {
console.log(`Generated ${outputFile}.h (${gzippedLength / 1024} KB)`);

const variables = {};
variables[`${variableName}:filename`] = outputFile;
variables[`${variableName}:filename_with_hash`] = serverFilename;
variables[`${variableName}:cdn_filename`] = inputFile;
variables[`${variableName}:local_filename`] = serverFilename;
variables[`${variableName}:size`] = gzippedLength;

return variables;
Expand Down
12 changes: 5 additions & 7 deletions web2/src/pageload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
const files = [
{
type: "stylesheet",
cdnPath: cdnBase + "{{bundle_css:filename}}",
localPath: "{{bundle_css:filename_with_hash}}",
cdnPath: cdnBase + "{{bundle_css:cdn_filename}}",
localPath: "{{bundle_css:local_filename}}",
size: parseInt("{{bundle_css:size}}", 10),
},
{
type: "script",
cdnPath: cdnBase + "{{bundle_js:filename}}",
localPath: "{{bundle_js:filename_with_hash}}",
cdnPath: cdnBase + "{{bundle_js:cdn_filename}}",
localPath: "{{bundle_js:local_filename}}",
size: parseInt("{{bundle_js:size}}", 10),
},
];
Expand All @@ -36,7 +36,7 @@
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response;
return Promise.resolve(response);
})
.catch((error) => {
if (retryCount < maxRetries) {
Expand All @@ -50,7 +50,6 @@

function tryLoadFile(file) {
return tryLoadUrl(file.cdnPath, file.size, 0, 0)
.then((response) => response.blob())
.catch(() => {
return tryLoadUrl(file.localPath, file.size);
});
Expand All @@ -61,7 +60,6 @@

function loadNextFile() {
if (currentFileIndex >= files.length) {
console.log("All files loaded");
document.getElementById("loading").style.display = "none";
return;
}
Expand Down

0 comments on commit dfbb2d0

Please sign in to comment.