- AMP:Building Accelerated Mobile Pages
- Ruadhan O'Donoghue
- 329字
- 2021-07-08 10:03:55
Web performance - why are web pages slow?
Web development is difficult to get right. The web technology stack is complex, and there are many things between the web server and the user's device that can contribute to poor performance.
There are some things that you have no control over, such as the user's network quality or device grade. But there are plenty of things that affect performance that you do have control over. Some of the most significant of these factors are page size, resource loading, number of HTTP requests, and slow JavaScript execution:
- Page size: In 2016, mobiForge (mobiforge.com) reported a sobering statistic: the average web page, at 2.3 MB, had grown as large as the original PC game, DOOM. Something is wrong when a web page needs to be the same size as a multi-level first-person shooter with an advanced 3D graphics engine.
Many things can contribute to page size, including images, videos, ads, and third-party libraries (which themselves can include further third-party code). - Resource loading: The order in which a page's resources are loaded can significantly affect the performance of the page. A naive approach to resource loading would be to just queue up all resources and download them as the page loads. But then network bandwidth and CPU resources are wasted on downloading and rendering items that may never be seen by the user. A smarter approach is to only load items as they are needed.
- Number of HTTP requests: Each external resource in a web page requires an HTTP request to fetch it. HTTP requests are slow, especially on mobile. HTTP requests can be reduced by inlining CSS and images where appropriate, and by including fewer external resources.
- Slow JavaScript execution: Today, there are JavaScript libraries for just about any task you can think of. Including and using JavaScript libraries has never been easier. But this poses problems on mobile, where every library chews through precious CPU cycles, contributing to laggy and unresponsive pages.
推薦閱讀
- 演進式架構(原書第2版)
- Spring 5.0 Microservices(Second Edition)
- Drupal 8 Blueprints
- 深度學習經(jīng)典案例解析:基于MATLAB
- Python 深度學習
- Designing Hyper-V Solutions
- Mastering Ubuntu Server
- 21天學通C++(第6版)
- Windows Server 2012 Unified Remote Access Planning and Deployment
- 人人都是網(wǎng)站分析師:從分析師的視角理解網(wǎng)站和解讀數(shù)據(jù)
- TradeStation交易應用實踐:量化方法構建贏家策略(原書第2版)
- Nginx Lua開發(fā)實戰(zhàn)
- Kotlin開發(fā)教程(全2冊)
- Android應用開發(fā)實戰(zhàn)
- Oracle 12c從入門到精通(視頻教學超值版)