release(v1.7.3): lightweight boot pipeline, dramatically faster first paint, deduped /api writes, sturdier uploads/auth
This commit is contained in:
20
public/js/defer-css.js
Normal file
20
public/js/defer-css.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Promote any preloaded styles to real stylesheets without inline handlers (CSP-safe)
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Promote any preloaded core CSS
|
||||
document.querySelectorAll('link[rel="preload"][as="style"][href]').forEach(link => {
|
||||
const href = link.getAttribute('href');
|
||||
if ([...document.querySelectorAll('link[rel="stylesheet"]')]
|
||||
.some(s => s.getAttribute('href') === href)) return;
|
||||
const sheet = document.createElement('link');
|
||||
sheet.rel = 'stylesheet';
|
||||
sheet.href = href;
|
||||
document.head.appendChild(sheet);
|
||||
});
|
||||
|
||||
|
||||
// Optionally load non-critical icon/extra font CSS after first paint:
|
||||
const extra = document.createElement('link');
|
||||
extra.rel = 'stylesheet';
|
||||
extra.href = '/css/vendor/material-icons.css?v={{APP_QVER}}';
|
||||
document.head.appendChild(extra);
|
||||
});
|
||||
Reference in New Issue
Block a user