|
Post by account_disabled on Jan 5, 2024 22:31:57 GMT -5
然后评估用户的环境并相应地增强体验的想法。一个简单的例子是最初加载低分辨率图像,然后根据用户拥有的带宽显示高分辨率图像。 这个想法是渐进增强的一部分,其中网络技术是分层的,以提供跨环境的最佳体验。渐进增强可以基于许多不同的因素。其中包括用户可以访问的技术,例如浏览器、操作系统和环境(例如互联网速度)。在这里,定义一组必须在能力最差的浏览器上工作的基本功能,并且仅在测试浏览器是否可以处理它之后才增加进一步的复杂性。 检测浏览器是否支持 HTML5 和 CSS 功能有助于我们编写条件代码以涵盖所有可能情况:在支持时增强和添加功能,同时对于不支持的设备和浏览器保持安全和简单。 减少功能测试 合并诸如Modernizr或has.js之类的。 功能测试库是一种常见的推荐做法。但是太多的开发人员实现了整个库;他们测试所有功能,即使只需要少量结果即可确定是否添加功能。 Tim Kadlec 报告了同一库(最小化的 jQuery 2.1.1)在多种设备上的解析和执行时间。这表明与桌面相比,实施这些库通 Whatsapp 号码列表 常会产生更大的移动性能成本(即使在新旧设备之间)。我们倾向于定制库,仅测试相关的网站功能。这将节省时间和宝贵的移动处理能力。 减少 Modernizr 测试库的大小 定制测试库至关重要。该图比较了实现整个库的大小(顶部),并将测试限制为我们需要的(底部)。(大预览) 服务器端优化 服务器响应时间是网站速度的关键因素:许多目标是低于 200 毫秒。但网络延迟(数据在服务器和设备之间移动时的延迟)是移动性能的真正瓶颈,导致移动用户的体。 验变慢。 这受网络速度的影响。根据Ofcom 的数据,英国流行 3G 和 4G 网络的平均下载速度分别为 6.1Mbps 和 15.1Mbps。有些人将此解释为对最大网站大小的明确限制。但实际情况更为复杂,因为速度会根据覆盖范围和环境背景而变化。当超出范围时,用户通常会连接到速度较慢的 Edge (E) 和 GPRS。 有多种技术可用于提高服务器端网站性能。 缓存、预渲染和静态内容 动态网页需要多个数据库查询,需要花费宝贵的时间来处理输出和格式化数据,然后呈现为浏览器可读的 HTML。建议缓存之前为该设备渲染的内容。对于返回的访问者,它不会从头开始处理,而是检查缓存,并且仅发送更新。 许多人还选择像Handlebars和Mustache这样的 JavaScript 模板库来处理 Web 内容。但解析和执行 JavaScri。
|
|