Skip to content

Commit

Permalink
Perf
Browse files Browse the repository at this point in the history
  • Loading branch information
MotorTruck1221 committed Apr 15, 2024
1 parent 866f01a commit fe0c667
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/public/js/eruda/create.js.min.js

This file was deleted.

1 change: 0 additions & 1 deletion src/public/js/eruda/rightClick.js.min.js

This file was deleted.

8 changes: 5 additions & 3 deletions src/public/js/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(async (sw) => {
//await registerRemoteListener(sw.active!)
console.log('Service Worker Ready');
setDefaultTransport();
await createTransportScripts()
setDefaultTransport()
});
navigator.serviceWorker.register('/sw.js', { scope: '/' })
navigator.serviceWorker.register('/sw.js', { scope: '/' })
}
function regSW() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(async (sw) => {
setDefaultTransport();
await createTransportScripts()
setDefaultTransport()
})
navigator.serviceWorker.register('/sw.js', { scope: '/' })
}
Expand Down
2 changes: 2 additions & 0 deletions src/public/js/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ function init() {
favicon: 'favicon.ico',
});
}


init();
20 changes: 20 additions & 0 deletions src/public/js/transports.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
const wispUrl = localStorage.getItem('wispUrl') || (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/";

function createTransportScripts() {
return new Promise((resolve) => {
const epoxyScript = document.createElement('script');
epoxyScript.src = 'epoxy/index.js';
//epoxyScript.defer = true;
document.body.appendChild(epoxyScript);
const libcurlScript = document.createElement('script');
libcurlScript.src = 'libcurl/index.cjs';
//libcurlScript.defer = true;
document.body.appendChild(libcurlScript);
//wait for the scripts to load
epoxyScript.onload = () => {
libcurlScript.onload = () => {
console.log('Transport Scripts Loaded');
resolve();
}
}
});
}

function setTransports(transport) {
function localStorageTransport() {
switch (localStorage.getItem('transports')) {
Expand Down
2 changes: 0 additions & 2 deletions src/views/layouts/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<title><%= yield_content :title %></title>
<link rel="stylesheet" href="css/globals.css">
<script src="baremux/bare.cjs" defer></script>
<script src="epoxy/index.js" defer></script>
<script src="libcurl/index.cjs" defer></script>
<script src="js/bareTransport/bareMod.<%= getExtension() %>" defer></script>
<script src="js/transports.<%= getExtension() %>" defer></script>
<script src="uv/uv.bundle.js" defer></script>
Expand Down

0 comments on commit fe0c667

Please sign in to comment.