-
Service Workers, the future for caching
This week I got the opportunity to experiment with the Service Worker API at work, in a lab session held by @OskarKarlsson. Although it is not supported in all browsers just yet, my initial impressions are pretty much that I love it. It feels a lot like what I would expect Application Cache to be but without the quirks. Not only can we use it as a “Cache Everything” solution, with service workers we’re also able to priorities how we want to read from the cache as well.
-
Making (JavaScript) Promises
When writing JavaScript code you often, if not always, end up writing something that is asynchronous. Whether it’s responding to File I/O, a AJAX request using or user interaction the standard method have been to use
callback functions
. Writing a function that use callbacks can look something like the following -
An Introduction to Goroutines
Goroutines, what are they exactly? According to the documentation they are a way to work with concurrency which basically means to execute functions at the same time. They’re called goroutines because the existing terms—threads, coroutines, processes, and so on—convey inaccurate connotations. A goroutine has a simple model: it is a function executing concurrently with other goroutines in the same address space. Unlike threads they are simpler to use and more memory efficent.
-
It's not Application Cache's Fault.. Sometimes.
At work we are currently building a mobile web application together with a client. We decided that we would a good idea to use Application Cache for offline mode as well as handling updates when we release new versions of the site. It’s been a long road and I kind of knew that we would hit roadblocks. But I never thought that they would just keep on coming. Although, I’ve learnt that it’s not only the App Caches fault.
-
Optimizing images using MozJPEG
Earlier this week I was at a meetup and got to hear Tobias Baldauf speak about Image Compression. He talked about tools like jpegoptim and jpegrescan and also the new compression formats webp and mozjpeg. If you haven’t seen the talk I suggest that you do take a look at it. If you don’t have time to watch it right now, then here are some cliff notes. Right now WebP is beating MozJPEG in compression (32.9% vs 12.1%) however, compression with MozJPEG yeild less dissimilarity between the original image and the compressed image than compression with webp (0.3% vs 0.09%).