Cache-Control
、ETag
配合浏览器缓存lazyload
或 IntersectionObserversrcset
根据设备分辨率加载合适大小<script src="app.js" defer></script><script src="analytics.js" async></script>php79 Bytes© 菜鸟-创作你的创作
defer
/ async
document.write
,避免渲染阻塞https://www.52runoob.com/archives/5971
工具 | 功能 |
---|---|
Google Lighthouse | 页面性能评分与优化建议 |
WebPageTest | 多地区加载速度测试 |
Chrome DevTools | 网络请求分析 |
Pingdom | 用户端加载速度分析 |
server { gzip on; gzip_types text/plain application/javascript text/css application/json; gzip_min_length 1024;}php125 Bytes© 菜鸟-创作你的创作
location ~* \.(js|css|png|jpg|jpeg|gif|webp|svg)$ { expires 30d; add_header Cache-Control "public";}php109 Bytes© 菜鸟-创作你的创作
<img class="lazy" data-src="image.jpg" alt="示例图片"><script> const images = document.querySelectorAll('.lazy'); const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if(entry.isIntersecting) { entry.target.src = entry.target.dataset.src; } }); }); images.forEach(img => observer.observe(img));</script>php366 Bytes© 菜鸟-创作你的创作
💡 总结
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。