Today I Learned - Rocky Kev

TIL what is npm Script

POSTED ON:

TAGS:

When we run a npm script, what happens?

In the blog post Speeding up the JavaScript ecosystem - npm scripts, the Author Marvin Hagemeister explains what's happening under the hood.

But also this amazing line:

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

Some notes:

Only use modules when they're needed

F'en Classes.

A recurring problem in various js tools is that they are composed of a couple of big classes that pull in everything instead of only the code you need. Those classes always start out small and with good intentions to be lean, but somehow they just get bigger and bigger.

I love this quote: "You wanted a banana but what you got was a gorilla holding the banana and the entire jungle." – Joe Armstrong


Related TILs

Tagged:

TIL what is npm Script

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

TIL fancy methods to transform Javascript Objects

You can use Object.entries(), Object.keys(), Object.fromEntries()...

TIL how to hide your JS code

ONE THING TO NOTE: Encrypting a script is stronger than obfuscation, both methods are still not adequate to protect secret content. Honestly, I don't think it's worth it on a production site, and instead just go with pure server-side if you want security. But it's fascinating.