Chrome implemented MHTML, but what is that?
Prateek Jadhwani
Founder at Destroyer Doggo | Game Developer (XBox DAP Grant Winner) | Author: "Getting Started with Web Components"
Remember the time when you were browsing that site and you wanted to view the page offline, so you Right Clicked and Saved that page? Yup, we are talking about the same thing.
And do you remember how it used to create a full fledged folder with all the resources like images, JavaScript and CSS files? Yes, we are still talking about the same thing.
Now imagine sending this web page via email. If you are a front-end developer, or have even a little bit of experience with creating html pages, you will realize one thing. Sending the page via email and making sure that the page works without any problems wont be possible that easily for big pages. You will need to aggregate all the resources into a single file[1] to make sure it works in the email. This is where MHTML comes into picture.
What is MHTML?
MHTML has a weird full form as per RFC 2557. It's called MIME Encapsulation of Aggregate Documents, such as HTML (MHTML) [1].
It is a specification designed to package or aggregate a web page and all the resources used into a single composite message structure such that the links or URIs used in the page may reference the resources from within that message. In layman's term. Let the page be served as a zipped file with everything packed rather than being served as one file which tries to access other files.
Interesting Stuff. Tell me when can I use it.
Well technically you are already using it. Here are three scenarios where you might have used it already.
- When you save a webpage nowadays, it gets saved as one single file on your system. That is MHTML version of that page[2].
- When you try to access an old page from the internet, say from the archives. That is MHTML page[2].
- If you are an android user, you can capture the snapshot of a web page for offline usage. This offline copy of the page is MHTML page[2].
Conslusion
Until this morning I had no idea what MHTML was. And when I learned about it, I thought about sharing this with other people. Chrome team says they implemented the spec in a little bit different way which tries to cover the missing scenarios in RFC 2557 [3], but feel free to look up the resources in the section below if you are interested.