Browser Networking
In two acts
Michael Lange
ACT I
Browser APIs
- Requesting data
- HTTP
- XHR
- fetch
- Streaming data
- ReadableStream
- Web Sockets
- SSE/EventSource
- WebRTC
- The evil that devs do
HTTP/1.1
- The protocol of the Internet.
- The "normal" way to request stuff
XMLHttpRequest
- A way to make HTTP Requests via JavaScript
- Has nothing to do with XML
- The work horse for AJAX
- Asynchronous JavaScript and XML
- Still has nothing to do with XML
Fetch
- The new way to make HTTP requests
- Much better name
- No cancellation*
*Cancellation coming soon
ReadableStream
- Modeled after node.js streams
- Built right into fetch
- Respond to events/chunks
Web Sockets
- Full Duplex streaming
- WS protocol has much less overhead than HTTP
ServerSentEvents
- Server uses text/event-stream
- Browser can connect to this EventSource
- Browser can subscribe to an event
- Or handle every message
- NO WRITES!
WebRTC
- Built on UDP
- Known for P2P capabilities
- Typecasted as an audio/video tool
- Has a data channel for arbitrary p2p data sharing
- Yes, there's already a browser-based bittorrent client built on WebRTC
HTTP/2
- Request multiplexing
- Server Push
- Compressed headers
- Fixes all the things!
HTTP/2 :(
- Spec doesn't require encryption
- All browsers do
Land of Gimmicks
Concatenation and Minification
Resource Inlining
Domain Sharding
ACT II
Browser & Network Conditions
- Where people use browsers
- Mobile networks are pretty bad
- There are worse networks
- So that's why people use lynx
When was the last time your datacenter went underground or through a tunnel?
Mobile Network Performance
The latency!
Network Congestion
What happens when only some requests finish?
Be mindful!
It's easy to forget how bad the Internet can be from the comfort of our homes.
Go further
Assuming no friction
The End!
Browser Networking Draft 1
By Michael Lange
Browser Networking Draft 1
- 316