Khả năng tương thích với trình duyệt
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.
Khi xây dựng ứng dụng web dựa trên nội dung, bạn cần xem xét những trình duyệt mà độc giả đang sử dụng. Một số người dùng có thể sử dụng trình duyệt cũ không hỗ trợ các tính năng mới nhất, trong khi một số người khác có thể đang sử dụng trình duyệt mới hơn có nhiều tính năng hơn. Tất cả người dùng đều có thể truy cập ứng dụng của bạn, bất kể lựa chọn trình duyệt của họ là gì.
Sử dụng tính năng nâng cao tăng dần hoặc bắt đầu bằng các tính năng cơ bản nhất mà tất cả trình duyệt đều hỗ trợ, sau đó thêm các tính năng bổ sung cho các trình duyệt mới hơn. Phát hiện tính năng là một chiến lược khác nhằm tiếp cận người dùng bằng trình duyệt cũ hoặc mới. Với tính năng phát hiện tính năng, bạn có thể xác định tính năng nào mà trình duyệt của người dùng hỗ trợ, sau đó bạn tải mã thích hợp. Ứng dụng của bạn phải sử dụng các tính năng mới nhất mà trình duyệt của người dùng có thể hỗ trợ.
Có một số điểm cần cân nhắc khi nhắm mục tiêu cả trình duyệt cũ và hiện đại. Trước tiên, bạn có thể cần phải sử dụng mã riêng cho các trình duyệt khác nhau. Điều này có thể khiến mã của bạn phức tạp và khó duy trì hơn. Có thể bạn sẽ không
dùng được các tính năng mới nhất trong mọi trình duyệt. Điều này có thể hạn chế chức năng của ứng dụng.
Tuỳ thuộc vào ứng dụng, các trình duyệt cũ có thể vẫn cần hỗ trợ vì lý do pháp lý hoặc trường hợp sử dụng trong kinh doanh. Nếu phần lớn người dùng sử dụng phần cứng cũ và không thể cập nhật, thì có thể cần đến các polyfill. Đoạn mã polyfill cung cấp các tính năng hiện đại cho các trình duyệt web cũ và có thể cho phép bạn sử dụng các công nghệ web và API hiện đại nhất trong khi vẫn đảm bảo khả năng tương thích với các trình duyệt cũ.
Có nhiều công cụ hữu ích để kiểm tra xem công nghệ hoặc API nào được sử dụng:
- Project Baseline: là một nỗ lực nhằm cải thiện trải nghiệm của nhà phát triển bằng cách cung cấp những gì hoạt động tốt trong các trình duyệt được hỗ trợ, đồng thời được Google và các hệ thống thường dùng khác hỗ trợ.
- Caniuse: là tài nguyên để tra cứu các API Web và xem trạng thái hỗ trợ trên tất cả các trình duyệt được theo dõi.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eWeb applications should be accessible to all users regardless of their browser choice, potentially using progressive enhancement or feature detection to cater to different browser capabilities.\u003c/p\u003e\n"],["\u003cp\u003eWhile supporting older browsers might necessitate using different code or limit access to the latest features, it can be crucial for legal compliance or business needs, especially when users rely on older hardware.\u003c/p\u003e\n"],["\u003cp\u003ePolyfills can bridge the gap between modern web technologies and older browsers, ensuring compatibility while enabling the use of the latest features.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize tools like Project Baseline and Caniuse to determine browser compatibility and make informed decisions about web development strategies.\u003c/p\u003e\n"]]],["When creating web applications, consider browser compatibility. Employ progressive enhancement by starting with basic features and adding advanced ones for newer browsers. Use feature detection to load appropriate code based on browser capabilities. Supporting both old and new browsers may increase code complexity and limit functionality. Polyfills can bridge the gap by adding modern capabilities to older browsers. Tools like Project Baseline and Caniuse help determine browser support for various technologies.\n"],null,["# Browser compatibility\n\nWhen building a content driven web application, it is important to consider\nwhich browsers your audience is using. Some might use older browsers that don't\nsupport the latest features, while others may be using newer browsers that have\nmore features. Your application is accessible to all users, regardless of their\nbrowser choice.\n\nUtilize progressive enhancement, or start with the most basic features that all\nbrowsers support, and then add additional features for newer browsers. Feature\ndetection is another strategy to reach users with dated or new browsers. With\nfeature detection, you can determine which features are supported by the user's\nbrowser, and then you load the appropriate code. Your application should use the\nmost up-to-date features that the user's browser can support.\n\nThere are a few tradeoffs to consider when targeting both old and modern\nbrowsers. First, you may need to use different code for various browsers. This\ncan make your code more complex and difficult to maintain. You might not be\nable\\\u003e to use the latest features in all browsers. This can limit the\nfunctionality of your application.\n\nDepending on the application, older browsers may still need support for legal\nreasons or business use cases. If the majority of the users are on older\nhardware and cannot update, then polyfills may be necessary. A polyfill provides\nmodern capabilities to older web browsers and can allow you to use the most\nmodern web technologies and APIs while still ensuring compatibility with old\nbrowsers.\n\nThere are many great tools to check what technologies or APIs are used:\n\n- [Project Baseline](https://web.dev/baseline/): is an effort to improve the experience of developers by providing what works well in supported browsers and is backed by Google and other commonly used systems.\n- [Caniuse](https://caniuse.com/): is a resource to look up Web APIs and see the support status across all tracked browsers."]]