v6.7.3: faster loading, and pages search engines can read
The bundles carried all thirteen translations at once and a page fetched them a third time as raw source; each page now loads only its own language. Alongside that: JavaScript is minified, the eight stylesheets are served as one file, the QR scanner is fetched after the app is up instead of on every visit, Inter ships once rather than five copies of the same file, and Font Awesome is subset to the 82 icons this app draws instead of all 2468. 1.85 MB across 43 requests becomes under 700 KB across 33. On mobile the page starts drawing in 1.6 s instead of 6.3 s and is usable in 4.5 s instead of 11 s. Pages also carry their text in the HTML now. Everything was drawn by JavaScript into an empty div, so crawlers saw correct metadata around nothing, and twelve of the thirteen language pages had never been shown to anyone. The documentation is published under /docs/ with a new FAQ, and unknown addresses return a real 404. Separately: the localized shells were served with the year-long immutable cache header meant for static assets, which pinned anyone who opened /de/ or /ru/ to that build. The header is fixed and the service worker refreshes what it cached. Claude-Session: https://claude.ai/code/session_014KjzTXxrhzYoDDWChYQ4u2
This commit is contained in:
@@ -41,6 +41,40 @@ const purgeLegacyOfferRecords = () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* QR generation and scanning live in their own bundle — 142 KB gzipped, the third
|
||||
* largest thing this site serves. It used to be a <script type="module"> in <head>,
|
||||
* which meant every first visit paid for it before the app was interactive, on a
|
||||
* screen that has no QR on it: the scanner only exists behind a button, and the
|
||||
* generator only runs once a channel is being created.
|
||||
*
|
||||
* So it is fetched after the app has mounted and the browser is idle. Every call site
|
||||
* already checks `typeof window.<fn> === 'function'` before using it, so arriving late
|
||||
* is not an error condition — but the scanner effect in app.jsx keys off this event to
|
||||
* start the camera for anyone who opened the modal in the meantime.
|
||||
*/
|
||||
const loadQrBundle = () => {
|
||||
if (window.__qrReady) return window.__qrReady;
|
||||
window.__qrReady = import('/dist/qr-local.js')
|
||||
.then(() => {
|
||||
window.dispatchEvent(new Event('securebit:qr-ready'));
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('QR bundle failed to load:', error && error.message);
|
||||
// Let a later attempt retry rather than caching the rejection forever.
|
||||
window.__qrReady = null;
|
||||
});
|
||||
return window.__qrReady;
|
||||
};
|
||||
|
||||
const scheduleQrBundle = () => {
|
||||
if (typeof window.requestIdleCallback === 'function') {
|
||||
window.requestIdleCallback(loadQrBundle, { timeout: 3000 });
|
||||
} else {
|
||||
setTimeout(loadQrBundle, 1200);
|
||||
}
|
||||
};
|
||||
|
||||
// Mount application once DOM and modules are ready
|
||||
const start = () => {
|
||||
purgeLegacyOfferRecords();
|
||||
@@ -49,6 +83,7 @@ const start = () => {
|
||||
} else if (window.DEBUG_MODE) {
|
||||
console.error('initializeApp is not defined on window');
|
||||
}
|
||||
scheduleQrBundle();
|
||||
};
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
|
||||
Reference in New Issue
Block a user