Skip to content

Commit

Permalink
Create ruffle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mountain658 committed Nov 29, 2023
1 parent 2c4f7af commit 6256d87
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ruffle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function loadScript(scriptUrl, options) {
var script = document.createElement('script');
script.src = scriptUrl;
script.onload = function() {
console.log('Script loaded successfully');
};
script.onerror = function() {
console.log('Failed to load script: ' + scriptUrl);
var backups = options && options.backups;
if (backups && backups.length > 0) {
console.log('Attempting to load backups...');
loadBackupScripts(backups, 0);
} else {
console.log('No backups available.');
}
};
document.head.appendChild(script);
}

function loadBackupScripts(backups, currentIndex) {
if (currentIndex >= backups.length) {
console.log('All backup scripts failed to load.');
return;
}

var backupScriptUrl = backups[currentIndex];
var backupScript = document.createElement('script');
backupScript.src = backupScriptUrl;
backupScript.onload = function() {
console.log('Backup script loaded successfully');
};
backupScript.onerror = function() {
console.log('Failed to load backup script: ' + backupScriptUrl);
loadBackupScripts(backups, currentIndex + 1);
};
document.head.appendChild(backupScript);
}

loadScript('https://unpkg.com/@ruffle-rs/ruffle', { backups: ['https://cdn.jsdelivr.net/npm/@ruffle-rs/ruffle/ruffle.min.js', './ruffle/ruffle.js'] });

2 comments on commit 6256d87

@vercel
Copy link

@vercel vercel bot commented on 6256d87 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 6256d87 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.