Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Quy tắc này sẽ kích hoạt khi PageSpeed Insights phát hiện thấy rằng có thể giảm kích thước của một trong các tài nguyên của bạn bằng cách giảm kích thước.
Tổng quan
Rút gọn là quá trình xoá dữ liệu không cần thiết hoặc dư thừa mà không ảnh hưởng đến cách trình duyệt xử lý tài nguyên, ví dụ: nhận xét và định dạng mã, xoá mã không dùng đến, sử dụng tên hàm và biến ngắn hơn, v.v.
Để giảm kích thước JavaScript, hãy thử UglifyJS. Trình biên dịch đóng cũng rất hiệu quả. Bạn có thể tạo một quy trình xây dựng sử dụng các công cụ này để rút gọn và đổi tên các tệp phát triển và lưu chúng vào một thư mục sản xuất.
Ngoài ra, Mô-đun PageSpeed tích hợp với máy chủ web Apache hoặc Nginx để tự động tối ưu hoá trang web của bạn, bao gồm cả việc giảm kích thước tài nguyên.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eThis documentation is outdated and refers to a deprecated version of PageSpeed Insights API (v4) which will be shut down.\u003c/p\u003e\n"],["\u003cp\u003eMinification is the process of removing unnecessary data from web resources (HTML, CSS, JavaScript) without impacting functionality, improving page load speed.\u003c/p\u003e\n"],["\u003cp\u003eYou can use tools like HTMLMinifier, CSSNano, csso, UglifyJS, and Closure Compiler to minify your resources.\u003c/p\u003e\n"],["\u003cp\u003eThe PageSpeed Module for Apache or Nginx servers can automatically optimize your site, including minification.\u003c/p\u003e\n"]]],["Minification reduces resource size by removing unnecessary data without affecting browser processing. Key actions include minifying HTML, CSS, and JavaScript. Use tools like HTMLMinifier for HTML, CSSNano or csso for CSS, and UglifyJS or Closure Compiler for JavaScript. A build process can automate minification, or the PageSpeed Module can optimize sites on Apache/Nginx servers. The content refers to PageSpeed Insights for identifying areas for minification.\n"],null,["# Minify Resources (HTML, CSS, and JavaScript)\n\n| **Deprecated** . This page was written for version 4 of the PageSpeed Insights API, which is deprecated and will be shut down in May 2019. [Version 5](/speed/docs/insights/v5/get-started) is the latest and provides both real-world data from the Chrome User Experience Report and lab data from Lighthouse.\n\nThis rules triggers when PageSpeed Insights detects that the size of one of your resources could\nbe reduced through minification.\n\n### Overview\n\nMinification refers to the process of removing unnecessary or redundant data without affecting how\nthe resource is processed by the browser - e.g. code comments and formatting, removing unused code,\nusing shorter variable and function names, and so on.\n\nSee [preprocessing \\& context-specific optimizations](/web/fundamentals/performance/optimizing-content-efficiency/optimize-encoding-and-transfer#minification-preprocessing--context-specific-optimizations) to learn more.\n\n### Recommendations\n\nYou should minify your HTML, CSS, and JavaScript resources:\n\n- **To minify HTML,** try [HTMLMinifier](https://github.com/kangax/html-minifier)\n- **To minify CSS,** try [CSSNano](https://github.com/ben-eb/cssnano) and [csso](https://github.com/css/csso).\n- **To minify JavaScript,** try [UglifyJS](https://github.com/mishoo/UglifyJS2). The [Closure Compiler](/closure/compiler) is also [very effective](https://github.com/samccone/The-cost-of-transpiling-es2015-in-2016#summary-of-findings). You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.\n\nAlternatively, the [PageSpeed Module](/speed/pagespeed/module),\nintegrates with an Apache or Nginx web server to automatically optimize your site, including resource minification.\n\nFeedback\n--------\n\nWas this page helpful? \nYes Great! Thank you for the feedback. If you have a specific, answerable question about using PageSpeed Insights, ask the question in English on [Stack\n| Overflow](https://stackoverflow.com/questions/tagged/pagespeed-insights). For general questions, feedback, and discussion, start a thread in the [mailing list](https://groups.google.com/forum/#!forum/pagespeed-insights-discuss).\nNo Sorry to hear that. If you have a specific, answerable question about using PageSpeed Insights, ask the question in English on [Stack\n| Overflow](https://stackoverflow.com/questions/tagged/pagespeed-insights). For general questions, feedback, and discussion, start a thread in the [mailing list](https://groups.google.com/forum/#!forum/pagespeed-insights-discuss)."]]