Service Workers

A List Apart runs an excellent article “Going Offline“.  In it, among other things, there’s one of the simplest explanations of the Service Workers technology that I’ve seen so far:

A service worker is like a cookie. Cookies are downloaded from a web server and installed in a browser. You can go to your browser’s preferences and see all the cookies that have been installed by sites you’ve visited. Cookies are very small and very simple little text files. A website can set a cookie, read a cookie, and update a cookie. A service worker script is much more powerful. It contains a set of instructions that the browser will consult before making any requests to the site that originally installed the service worker.

A service worker is like a virus. When you visit a website, a service worker is surreptitiously installed in the background. Afterwards, whenever you make a request to that website, your request will be intercepted by the service worker first. Your computer or phone becomes the home for service workers lurking in wait, ready to perform man-in-the-middle attacks. Don’t panic. A service worker can only handle requests for the site that originally installed that service worker. When you write a service worker, you can only use it to perform man-in-the-middle attacks on your own website.

A service worker is like a toolbox. By itself, a service worker can’t do much. But it allows you to access some very powerful browser features, like the Fetch API, the Cache API, and even notifications. API stands for Application Programming Interface, which sounds very fancy but really just means a tool that you can program however you want. You can write a set of instructions in your service worker to take advantage of these tools. Most of your instructions will be written as “when this happens, reach for this tool.” If, for instance, the network connection fails, you can instruct the service worker to retrieve a backup file using the Cache API.

The deepest reason why modern JavaScript frameworks exist

The deepest reason why modern JavaScript frameworks exist” is a nice article looking at the crazy world of JavaScript frameworks and exploring why things are how they are.  The conclusions from the article are:

  • The main problem modern JavaScript frameworks solve is keeping the UI in sync with the state.
  • It is not possible to write complex, efficient and easy to maintain UIs with Vanilla JavaScript.
  • Web components do not provide a solution to this problem.
  • It’s not that hard to make your own framework using an existing Virtual DOM library. But I’m not suggesting you to do that!

Read the whole thing for some examples and explanations.

How JavaScript works: the mechanics of Web Push Notifications

“How JavaScript works” is a series of articles on SessionStack, describing some of the lesser known bits and pieces of JavaScript.  One particular chapter that caught my attention is “The Mechanics of Web Push Notifications“.

Push and notification are two different APIs.

  • Push — it is invoked when the server supplies information to a Service Worker.
  • Notification — this is the action of a Service Worker or a script in a web app that shows information to the user.

Awesome list of Important Podcasts for software engineers

Awesome podcasts is a curated list of podcasts for software engineers.  The list includes a whole lot of sections – one for each programming language out there, generic software engineering, tools, etc.

Also, have a look at this blog post I did a while back.

Vue.js — answering the Why, after 15 months

Harshal Patil shares his positive experience with the Vue.js JavaScript framework, after using it for just over a year in “Vue.js — answering the Why, after 15 months“.  As many before him, he focuses on the virtual DOM, optional but powerful build system, state management, single file components, performance, testability, and a few other benefits of this particular technology.

It’s good overall article for those who are still deciding which JavaScript framework to go with for their next project.