JS Magic Hall: Data URI Scheme Introduction

Source: Internet
Author: User
Tags website performance

First, preface

In Friday, the company's internal any Topic Conf. I shared this topic with my colleagues, some colleagues said this useful, some colleagues said this is useless, and later extended to the topic of website performance, we discuss the intensity of this topic is also good. In this article, regardless of whether it is useful or not, just record theoretical knowledge. Also hope that everyone together to share the actual combat experience Ah!

Second, start with the HTTP URI scheme

For <a href="http://github.com">http URI scheme</a> I think we should all be familiar with it, The href attribute value http://github.com is the HTTP URI scheme, so what is the data URI scheme? In fact, it is like a data:text/jpeg;base64,xingsxxiangjijigsag=== resource link, which generally appears in the SRC attribute of the IMG element.

The purpose of data URI scheme is to embed the BASE64 encoded in the Web page, thus reducing the number of links to the requested resource. The data URI scheme above base64, after which the character is Base64 encoded, the browser will decode it and render the picture resource.

Third, Data URI scheme format

data:① [<mime type>]② [; charset=<charset>]③ [; <encoding>]④ , <encoded data>⑤

①. data : Name of the agreement;

②. [<mime Type>] : Optional, data type (image/png, Text/plain, etc.)

③. [; charset=<charset>] : Optional, Character set encoding method

④. [; <encoding>] : Data encoding Method (default us-ascii,base64 two kinds)

⑤. , <encoded data> : Encoded data

Attention:

[A]. The default value of [<mime Type>][;charset=<charset>] is the value of the field Content-type in the HTTP Header;

[b]. [; <encoding>] The default value is Us-ascii

Iv. Advantages & Disadvantages

Five, optimization program

VI. Browser support

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.