Data URI
Data URI (Sơ đồ Dữ liệu Nội tuyến)
Sơ đồ URL nhúng nội dung tệp trực tiếp trong HTML, CSS hoặc JavaScript sử dụng định dạng data:[mediatype][;base64],data, loại bỏ nhu cầu yêu cầu HTTP riêng để lấy tài nguyên.
Chi tiết kỹ thuật
Data URI tuân theo cú pháp: data:[
Ví dụ
```javascript
// Encode string to Base64
const encoded = btoa('Hello, World!'); // 'SGVsbG8sIFdvcmxkIQ=='
// Decode Base64 to string
const decoded = atob('SGVsbG8sIFdvcmxkIQ=='); // 'Hello, World!'
// File to Base64 Data URI
const reader = new FileReader();
reader.onload = () => console.log(reader.result);
// → 'data:image/png;base64,iVBORw0KGgo...'
reader.readAsDataURL(file);
```