Skip to content

perf: 拆分巨型HTML文件 + 性能优化#1

Open
crazyjtt11 wants to merge 3 commits into
EDT-Pages:mainfrom
crazyjtt11:main
Open

perf: 拆分巨型HTML文件 + 性能优化#1
crazyjtt11 wants to merge 3 commits into
EDT-Pages:mainfrom
crazyjtt11:main

Conversation

@crazyjtt11

Copy link
Copy Markdown

优化内容

1. CSS/JS 文件拆分

  • admin/index.html 从 808KB 单文件拆分为:
    • index.html (136KB) — 纯HTML结构
    • admin-style.css (175KB) — 样式文件,可独立缓存
    • admin-app.js (390KB) — 逻辑文件,可独立缓存
  • 浏览器改HTML时不用重新下载CSS/JS,加载速度提升显著

2. Leaflet 地图懒加载

  • 移除 <head> 中的 Leaflet CSS/JS 同步加载
  • 改为按需动态加载(打开地图模块时才加载)
  • 首屏减少 ~140KB

3. 全局错误边界

  • 添加 window.onerror + unhandledrejection 捕获
  • 用户可见的错误提示 toast

4. 公共CSS提取

  • 提取 admin 和 login 共享样式到 common.css
  • 添加 prefers-reduced-motion 媒体查询(无障碍)

5. GitHub Pages 兼容

  • 添加 .nojekyll 文件

文件结构变化

新增: .nojekyll
新增: common.css (共享样式)
新增: admin/admin-style.css
新增: admin/admin-app.js
新增: login/login-style.css
修改: admin/index.html (HTML only)
修改: login/index.html (引用外部CSS)

Hermes Agent added 3 commits May 3, 2026 23:47
- Split admin/index.html (808KB) into separate files:
  - index.html (136KB) + admin-style.css (175KB) + admin-app.js (390KB)
  - CSS/JS now cacheable independently by browser
- Lazy-load Leaflet map library (saves ~140KB from initial page load)
- Add global error boundary (window.onerror + unhandledrejection)
- Extract shared CSS into common.css (admin + login)
- Split login CSS into common.css + login-style.css
- Add .nojekyll for GitHub Pages compatibility
- Add prefers-reduced-motion media query for accessibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant