JavaScript allows calling a function with a different number of arguments than the expected number of parameters, i.e., one can pass fewer or more arguments than the declared formal parameters. The former case is called under-application and the latter is called over-application.

In the under-application case, the remaining parameters get assigned the undefined value. In the over-application case, the remaining arguments can be accessed by using the rest parameter and the arguments property, or they are simply superfluous and they can be ignored. Many Web/NodeJS frameworks nowadays use this JS feature to accept optional parameters and create a more flexible API.

Until recently, V8 had a special machinery to deal with arguments size mismatch: the arguments adaptor frame. Unfortunately, argument adaption comes at a performance cost, but is commonly needed in modern front-end and middleware frameworks. It turns out that, with a clever trick, we can remove this extra frame, simplify the V8 codebase and get rid of almost the entire overhead.

We can calculate the performance impact of removing the arguments adaptor frame through a micro-benchmark.

Read More

Vue Native is a framework to build cross platform native mobile apps using JavaScript

After trying out Deno I got passionate about it. This post introduces my first Deno module, a simple preprocessor for HTML files that runs Deno where the new <deno> tag is specified. How useful can a simple file preprocessor be? What can it help build?

When explaining a technology, we have to decide how to approach its shortcomings. There might be mistakes in its design, or it might have usability problems, or it might be unreliable. How do we approach these and how much emphasis do we place on them?

One approach is: “This tool has a lot of problems, but we’ll show you how to avoid them.” That can demotivate the learner: “Why am I learning this thing if it has so many problems?”

In 2016, Sam Saccone discovered a vulnerability that allows adversaries to run arbitrary scripts when installing an NPM package of theirs.

Dec 22, 2020

This week, the React team previewed zero-bundle-size React Server Components, which aim to enable modern UX with a server-driven mental model. This is quite different to Server-side Rendering (SSR) of components and could result in significantly smaller client-side JavaScript bundles.

I’m quite excited about the direction of this work, and while it isn’t yet production ready, is worth keeping on your radar. I’d heavily recommend reading the RFC or watching Dan and Lauren’s talk for more detail.

Read More

You might think dividing your JavaScript into multiple bundles will help improve page load performance. When done incorrectly with Webpacker, it’s possible to make things worse.

This mistake appears relatively common. As I’ll share in this post, I’ve discovered several of my favorite Rails applications are making browsers download and parse more JavaScript than necessary even while attempting to send less.

Dec 20, 2020

This is a Javascript program for designing Celtic knots. Initially the display is a simple weave of intersecting threads. You can design a knot by clicking on the points where the threads intersect. The program ensures that your knot is always properly woven (over then under). Your knot will look best if it has some symmetry or pattern to it (for bonus points, use a single thread).

Dec 8, 2020

Ok so why exactly doesn’t the Fetch API have progress events, like the old XMLHttpRequest API? What am I missing here?

PS
Dec 8, 2020

Ah, looks like Fetch has progress update events for downloads, but not uploads. But why?

Stencil is a React-inspired web component library. It is using the same JSX as React and some of the same concepts (Render function, props, state). However, Stencil differs as it compiles to an optimal bundle, creating Virtual DOM that is consolidated directly into the DOM itself (no VDOM to VDOM comparison). The result is standard web components with optimal performance.

Dec 3, 2020

This looks interesting. Maybe I need to look into replacing webpack…

Nov 11, 2020

It’s historically been difficult for web developers to understand how the JavaScript in their apps performs in a wide range of cirumstances on real user devices. They’ve had to instrument code with poorly performing profiling hooks that could slow down page execution, without having the ability to collect stack samples efficiently. This is where the proposed native JavaScript self-profiling API could come in very useful.

This API allows web developers to efficiently identify costly hotspots during page load and user-interactions in their JavaScript. The API also enables you can do things like allocate CPU budgets to individual features implemented on a page, find low-priority code that’s executing in the background and wasting power or just client-side work that’s unnecessary.

Read More
Javascript

Share and discuss the Javascript programming language.

Created on Oct 23, 2020
By @root