Converting to Asynchronous Code Using IIFE

26 May 2020

by Thomas

I have not seen too much written about IIFEs in Javascript, but I think that they are a super useful tool for converting chunks of synchronous code to execute asynchronously.

In a nutshell, an IIFE is just a function that you execute at the same time you define it. The following is an example of a Hello World function running as a normal function and as an IIFE.

Go ahead and copy paste that into a file and run it, I’ll wait. You should see