Disabling file input field cancels upload

An interesting little "feature" I stumbled across: when the file input field of an HTML form is disabled right before a submission, that field will be empty. Some pseudo code which illustrates the setup: ... <script> function submitForm(){ var form = document.getElementById("form"); var file = document.getElementById("file"); file.disabled = true; form.submit(); } </script> <body> <form id="form"> … Continue reading Disabling file input field cancels upload →

Force-enabling Firefox’ reader view

TL;DR: Prepend "about:reader?url=" to any website URL to force reader view in Firefox I'm in love with Firefox' reader view. It not only removes ads, nag-screens, subscription prompts and other clutter from articles but it's typographical choices often are better than the (well-intended) choices of the author. I also value the consistent look and feel … Continue reading Force-enabling Firefox’ reader view →

Error handling for failed network requests with service workers

Most service worker code samples show only the happy path where the fetched resource will eventually be available, eg: self.addEventListener('fetch', event => { // Skip cross-origin requests, like those for Google Analytics. if (event.request.url.startsWith(self.location.origin)) { event.respondWith( caches.match(event.request).then(cachedResponse => { if (cachedResponse) { return cachedResponse; } return caches.open(RUNTIME).then(cache => { return fetch(event.request).then(response => { // Put … Continue reading Error handling for failed network requests with service workers →

The Model-View-Presenter-Controller pattern

In this post I'll talk about the MVPC (Model-View-Presenter-Controller) design pattern I use in client applications such as progressive web apps and mobile clients. It can be best understood as an evolution of the MVC (model-view-controller) pattern past the MVP (model-view-presenter) pattern. The basics: MVC and MVP You might want to skip this section if … Continue reading The Model-View-Presenter-Controller pattern →