User agent as a runtime
The other day, after experiencing a white screen of death, Markos asked a good question. I couldn't fit my thoughts into twitter so I've tried to articulate them a bit better here.
TIL “This webpage was reloaded because it was using significant energy.” just because I thought I could “trust” webpages in the background but not really no right @SlackHQ? https://t.co/uZVW6Doo8c— Markos Charatzas (@qnoid) April 28, 2018
@stephanierieger@bryanrieger@decadecity can I get your opinion on this and what it means for/how it may affect the web?— Markos Charatzas (@qnoid) May 11, 2018
Treating the browser as a runtime environment for GUI programming has gained acceptance and adoption over the years - and I'm not here to argue against that or try and justify a difference between "the document web" and "the app web". However, what you're seeing here is the dislocation of expectations that can occur when the fundamental nature of the environment isn't fully considered.
There's a key piece of terminology here: it's a "user agent" - not a "web browser". If you are going to treat it as a runtime the first thing to be aware of is that it's the agent of the user, as a developer it's not your runtime. Following on from this is that there are more things about this environment that are out of your control than are within it - the range of browsers, operating systems, hardware, networks, AdBlockers, &c. is vast.
However, there is one environment where you have complete control and none of these things are an issue - tellingly, it's the environment in which front end devs (and I include myself here) spend most of their time:
localhost - and typically
localhost viewed in Chrome on an expensive machine. If most of your contact time with your code is in this kind of situation you're simply not going to encounter the type of issues it's going to face in the wild. Added to which, they're often prohibitively hard to simulate.
Ultimately you can't control when and how things go wrong but you do have some control over what happens. This is why progressive enhancement exists.