This is the code repository for the course Browser JavaScript and Event Loop
Note
Every browser may differ in their implementation which may result in different behaviours when code execution happens.
This course takes Google Chrome as browser of choice. It is a great idea to have it installed on your machine, if haven't already. This will help you replicate the results as explained in the course.
- Clone the repository
git clone git@github.com:bonsaiilabs/browser-javascript-and-event-loop.git
- Get inside the project root
cd browser-javascript-event-loop
- Open the folder in your favorite editor
- Open Google Chrome. Open the Developer Tools.
- Open the Console panel
- Copy the code from an existing file. Paste in the Chrome Developer Tools Console. Press Enter
↩
. - You should see the output in the console now.
- Apple's JavaScript Engine is called JavaScript Core
- Microsoft JScript Engine is known as Chakra
- List of JavaScript Engines
- ECMAScript is a scripting-language specification to standardize JavaScript
setTimeout
is a method on Window which is an interface available on DOM API- Relationship between Chrome and Chromium
About Chrome JavaScript Engine - V8
- Use caniuse.com to search for feature support in browsers
- List of the Web APIs specifications by WHATWG
- List of Web APIs specifications by W3C
- DOM is standardized by W3C
- A browser engine is also known as rendering engine
- Gecko is the rendering engine for Mozilla Firefox browser.
- Webkit is the rendering engine for Apple Safari browser
- Blink is the rendering engine for Google Chrome browser
- EdgeHTML is the rendering engine for Microsoft Edge Browser.
- Example of
fetch
API implementation by browser engines
a. Gecko (Mozilla)
b. Webkit (Safari)
c. Blink (Chrome)
c. EdgeHTML (Edge)
- Gecko (Mozilla) - setTimeout, setInterval
- Webkit (Safari) - setTimeout, setInterval
- Blink (Chrome) - setTimeout, setInterval
- Chrome Process Models
- Utility Process. The Utility Process is a type of Process
- Plugin Process architecture. The Pepper Plugin implementation is available here
- GPU Process. The documentation of 3D APIs in Mac is available here
- Inter Process Communication (IPC)
- Network Service in Chrome
- Moving Chrome Audio to separate process
- Mojofication of Chrome Audio IPC
- Sandbox architecture.
- Sandboxed Chrome Processes
- Sandbox FAQs
- How Blink works
- What Blink does
- Chrome Multi-process architecture
Reference to Chromium Codebase
- Blink directory structure
- Off-main thread runs the task in worker pool
- Task Scheduling in Blink
- Blink Scheduler
- Task Queues and Ordering in Blink Scheduler
- List of Task Sources known to Blink
- Event Loop in Chromium manages the microtask queue
- Promise reactions are queued as microtask
- message_loop is the Chromium's abstraction for event loops. See Part 3: Message loops in codelabs. The event loop implementation is different for every platform. View the message_loop directory structure to locate header files for
android
,ios
,mac
, and many more. - Every thread has its own event loop
- Blink uses V8 APIs
- The source for main thread scheduler
setTimeout
callback is queued as a Task. See step 18 of timer initialization steps- Event Loop Processing Model
- User agents must use event loops to coordinate events, user interaction, scripts, rendering, and networking.
- User interaction (e.g. click events) are queued as Tasks as defined in user interaction task source
- Rendering Opportunity under the event loop processing model.
fetch
queues a Task. See step 18 of Main fetch
Please do not use the gif files for commercial purposes.