Web Bundles
New features of Chrome Developer Tools
Bundling a complete website into a single file and making it shareable opens up new use cases for the web. Imagine one you can:
- Create your own content and distribute it in various ways, without network restrictions
- Share network applications or network content with your friends via Bluetooth or Wi-Fi Direct
- Carry your website on your own USB or even host it on your own local network
The Web Bundles API is a cutting-edge proposal that allows you to do all this work.
The Web Bundles API is currently only supported by experimental flags in Chromium-based browsers.
Web Bundle is a file format used to encapsulate one or more HTTP resources in a single file. It can contain one or more HTML files, JavaScript files, images or style sheets.
Web Bundles, more formally known as Bundled HTTP Exchanges, are part of the Web Packaging proposal.
The HTTP resources in the Web Bundle are indexed by the request URL, and you can choose to have a signature with guaranteed resources. The signature allows the browser to understand and verify the source of each resource, and treat each resource as coming from its true source. This is similar to how Signed HTTP Exchanges (a feature used to sign individual HTTP resources) are handled.
Explaining Web Bundles
To be precise, Web Bundle is a CBOR file with a .wbn extension (by convention), which packages HTTP resources into a binary format and provides services in the application/webbundle MIME type. You can read more about it in the top-level structure section of the draft specification.
Web Bundles have several unique features:
- Package multiple pages, package a complete website into one file
- Enable executable JavaScript, which is different from MHTML
- Use HTTP variants for content negotiation, even if the bundle is used offline, you can also use the Accept-Language header for internationalization
- When cryptographically signed by its publisher, load in the context of its source
- Load almost instantly when served locally
These features have opened up multiple scenarios. A common solution is to be able to build a stand-alone Web application that can be easily shared and used without an Internet connection. For example, suppose you and a friend are on a plane from Tokyo to San Francisco. You don't like in-flight entertainment. Your friend is playing an interesting online game called PROXX and tells you that they download the game as a Web Bundle before boarding. It can work perfectly offline. Before Web Bundles, the story will end here. You either have to take turns to play games on your friends' devices or find other things to pass the time. But with Web Bundles, you can now do the following:
- Ask your friends to share the game's .wbn file. For example, you can use a file sharing application to easily share files peer-to-peer.
- Open the .wbn file in a browser that supports Web Bundle.
- Start playing the game on your own device and try to beat the high scores of your friends.
You can open the preview function for Web Bundles requests in Chrome Developer Tools.
Visit chrome://flags, visit tab\#enable-experimental-web-platform-feature, enable this feature:
enable-experimental-web-platform-features
More original articles by Jerry, all in: "Wang Zixi":
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。