---
title: "A case for weak dependencies in JavaScript"
publication: "JavaScript Weekly"
issue: 515
published_at: "2020-11-20"
canonical_url: "https://javascriptweekly.com/issues/515"
---

Plus TypeScript 4.1, Prettier 2.2, and how to use npm packages on CodePen.       

#515 — November 20, 2020 

[Unsubscribe](https://javascriptweekly.com/leave/*|UID|*)|[Read on the Web](https://javascriptweekly.com/issues/515)   

JavaScript Weekly 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/v1605891954/wpip59mgcqxzixazms8d.png)](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/)  

[TypeScript 4.1 Released](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/) — The ever popular ‘JavaScript with types’ takes more steps forward with template literal types, key remapping in mapped types, recursive conditional types, and support for React 17’s `jsx` and `jsxs` factory functions. If you’re a _Create React App_ user though, don’t rush to upgrade just yet as a few issues have been noted. 

Daniel Rosenwasser (Microsoft)   

[A Tale of Going from JavaScript to WebAssembly](https://engineering.q42.nl/webassembly/) — A developer of a ‘ultra resolution’ storytelling platform tells the tale of upgrading their Web client’s performance by moving from a pure JavaScript approach to one turbocharged with WebAssembly. There’s a lot to learn here. 

Marcel Duin   [![\](https://copm.s3.amazonaws.com/c0d5aca9.png)](https://blog.newrelic.com/product-news/monitor-frontend-performance-with-user-centric-performance-metrics/?utm_campaign=FY21-Q3-DEV-OBSV-AMER-JSW-NL-None-B_MFEP&utm_medium=NL&utm_source=JSW&utm_content=B_MFEP&fiscal_year=FY21&quarter=Q3&gtm=DEV&program=OBSV&ad_type=None&geo=AMER) 

[Monitor Frontend Performance With User-Centric Metrics](https://blog.newrelic.com/product-news/monitor-frontend-performance-with-user-centric-performance-metrics/?utm_campaign=FY21-Q3-DEV-OBSV-AMER-JSW-NL-None-B_MFEP&utm_medium=NL&utm_source=JSW&utm_content=B_MFEP&fiscal_year=FY21&quarter=Q3&gtm=DEV&program=OBSV&ad_type=None&geo=AMER) — Traditional metrics like page load aren’t enough to guarantee that you're providing a solid user experience. Learn to track interactivity metrics like “firstInteraction” so you can build for better impact, and keep users coming back. 

New Relic sponsor   

[Prettier 2.2 Released](https://prettier.io/blog/2020/11/20/2.2.0.html) — The popular opinionated code formatter gains TypeScript 4.1 support, comes as ES modules so you can use it directly within the browser, and supports two new JavaScript parsers: [espress](https://github.com/eslint/espree) and [meriyah.](https://github.com/meriyah/meriyah) 

Sosuke Suzuki   

[Electron 11 Released with Experimental Apple Silicon Support](https://www.electronjs.org/releases/stable#11.0.0) — The popular cross platform desktop app environment upgrades its dependencies across the board (hi Chromium 87!) and [begins to take steps](https://www.electronjs.org/blog/apple-silicon) into the Darwin arm64 world. 

GitHub / OpenJS Foundation     

**⚡️ Quick bytes:** 

- Chrome 87 has changed [how background tabs use resources](https://blog.chromium.org/2020/11/tab-throttling-and-more-performance.html) and JavaScript timer wakeups will [now be throttled](https://docs.google.com/document/d/11FhKHRcABGS4SWPFGwoL6g0ALMqrFKapCk5ZTKKupEk/view) to once per minute.
- Firefox 83, released this week, brings [significant JS performance improvements](https://hacks.mozilla.org/2020/11/warp-improved-js-performance-in-firefox-83/) through an updated approach to JIT compilation.
- An interesting [Twitter thread telling the story](https://twitter.com/frontstuff_io/status/1329553850693525505) of how so many tools and moving parts can make debugging seemingly straightforward issues seem like advanced plumbing.
- _Smashing Magazine_ has [a new TypeScript book out](https://www.smashingmagazine.com/2020/11/typescript-in-50-lessons-release/) and they always make great stuff.
- It's more [_Frontend Focus_](https://frontendfoc.us/?ref=jsw) territory but [Tailwind CSS 2.0 is out.](https://blog.tailwindcss.com/tailwindcss-v2)
- Jordan Harband is [stepping down](https://twitter.com/ljharb/status/1328278033363476480) as editor of the JS spec once ES2020 is final early next year.   

📚 Tutorials, Opinions and Stories  

[The Case for Weak Dependencies in JS](https://lea.verou.me/2020/11/the-case-for-weak-dependencies-in-js/) — If you’re using ES modules and want to check if one is present before using it in some optional way, what do you do? Lea explains why this would be useful and shares some ideas with how it could be implemented. 

Lea Verou   

[The Most Accurate Way to Schedule a Function in the Browser](https://medium.com/teads-engineering/the-most-accurate-way-to-schedule-a-function-in-a-web-browser-eadcd164da12) — A detailed analysis of three JavaScript timeout strategies and how they perform in thousands of web contexts. A bit of a micro-optimization for sure, but it’s interesting to dig into the weeds like this. 

Benoit Ruiz   

[10 React Security Best Practices](https://snyk.co/ucTIz) — A checklist to help you and your team find and fix security issues in your React applications. 

Snyk sponsor   

[Importing React Through the Ages](https://epicreact.dev/importing-react-through-the-ages/) — Kent looks at the wide variety of ways you can import React now and why he prefers a specific one. 

Kent C. Dodds   

[Creating WebGL Effects with CurtainsJS](https://css-tricks.com/creating-webgl-effects-with-curtainsjs/) — A way to add neat WebGL effects to <image> and <video> elements of an already “completed” web page. 

Zach Saucier   

[What’s New In Vue 3?](https://www.smashingmagazine.com/2020/11/new-vue3-update/) — [Vue 3](https://github.com/vuejs/vue-next/releases/tag/v3.0.0) has already been out for two months, but if you’ve not tried it out or just want to see some practical examples of its changes, this is for you. 

Timi Omoyeni   

[A Super Simple Start to Firebase Functions](https://kentcdodds.com/blog/super-simple-start-to-firebase-functions) — I find Google’s cloud services hard to navigate at the best of times so this sort of introduction is always much welcomed. 

Kent C Dodds   

[Introduction to Fullstack, Type-Safe GraphQL](https://dev.to/prisma/complete-introduction-to-fullstack-type-safe-graphql-feat-next-js-nexus-prisma-c5) — This tutorial teaches you how to build from scratch an entirely type-safe, fullstack web app, using GraphQL with a database attached. 

Prisma sponsor   

[The Difference Between Event Handlers and `addEventListener`](https://medium.com/dailyjs/whats-the-difference-between-event-handlers-addeventlistener-in-js-963431f05c34?sk=f39bb3a065f339d1a58cc379dc1387c6) — Let’s say you have a `button` element. You can assign a function to `button.onclick` to catch click events _or_ use `button.addEventListener("click", ...)` – how do they differ? 

Twan Mulder beginner   

[Integrating Cobol(!) with JavaScript](https://medium.com/graalvm/integrating-cobol-with-javascript-c2d1ffe00678) — Run COBOL applications and modify them with JavaScript on GraalVM. Not likely to be something many of you will want or need to do, but it’s interesting! 

Christoph Schobesberger   

[We Chose Ember in 2015 and It's Still A Good Decision in 2020](https://nothingventured.rocks/we-chose-ember-in-2015-and-it-is-still-a-good-decision-in-2020-c2eb1502a20a) 
Tomek Nieżurawski   

[Building Modern Native Add-ons for Node in 2020](https://nodejs.medium.com/building-modern-native-add-ons-for-node-js-in-2020-cd3992c68e0) 
Wu, Schulhof, Schlight, Eady, Dawson, and Del Gobbo   

[Angular CLI: Three Options You Didn't Know About the Component Schematic](https://www.amadousall.com/angular-cli-3-options-about-the-component-schematic/) 
Amadou Sall  

🛠 Code & Tools 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/ryemzmjjuubebwhjlldy.jpg)](https://blog.codepen.io/2020/11/18/skypack-codepen/)  

[How Skypack Lets You Use `npm` Packages on CodePen](https://blog.codepen.io/2020/11/18/skypack-codepen/) — I’m a huge fan of CodePen for throwing together quick Web and JavaScript experiments, but loading dependencies has always been a bit old-school. No more. [Skypack](https://www.skypack.dev/) and ES6 imports now let you bring in whatever npm packages you need. 

CodePen Blog   

[jose: Universal 'JSON Web Almost Everything'](https://github.com/panva/jose) — Did you know there were so many “JSON Web” specs? JSON Web Signature, JSON Web Tokens, JSON Web Encryption, and more. This library aims to tackle most of them in both Node and browser. JWA, JWS, JWE, JWT, JWK and more are here. 

Filip Skokan   

[Momoa JSON: A JSON Parser, Tokenizer, Traverser, and Printer](https://github.com/humanwhocodes/momoa) — Useful for a more fine-grained approach to parsing JSON data that’s not covered by `JSON.parse()` 

Nicholas C. Zakas   

[Building the Best Web Gallery, and Why the Heck It Was So Hard](https://www.wix.engineering/post/building-the-best-web-gallery-and-why-the-hell-it-was-so-hard) 

Wix Engineering sponsor   

[A One Line Function to Generate a Unique String ID](https://gist.github.com/SimonHoiberg/ad2710c8626c5a74cddd8f6385795cc0) — For when a UUID is overkill. 

Simon Høiberg   

[Harold: A CLI Tool That Compares Frontend Project Bundles in Size](https://github.com/funbox/harold) — This tool makes it easier to compare bundle sizes by taking snapshots that you can then review to manage how a project’s size is changing. 

FunBox   

[Immer 8.0: The Popular Immutable State Library](https://github.com/immerjs/immer)   

[Cosha 1.1: Add Colorful Shadows to Web Images](https://github.com/robinloeffel/cosha)   

[VeeValidate: Template Based Validation for Vue.js](https://vee-validate.logaretm.com/v4)   

[vue-use-infinite-scroll: A Vue Composition Function to Make Infinite Scroll Simple](https://github.com/jfet97/vue-use-infinite-scroll)   

[Ditox: 'Detoxed' Dependency Injection for JS, TypeScript and Flow](https://github.com/mnasyrov/ditox)  

💻 Jobs  

[Find a Job Through Vettery](https://www.vettery.com/tech?utm_source=newsletter&utm_medium=cooper-javascriptweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77584) — Create a profile on Vettery to connect with hiring managers at startups and Fortune 500 companies. It's free for job-seekers. 

Vettery  

🎵 A brief musical aside.. 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/v1605887535/qpddop0bqflgotcuijzf.png)](https://codepen.io/gregh/pen/zNzvOm)  

Hit play to start the beat and then [jam along on the blues guitar](https://codepen.io/gregh/pen/zNzvOm) to express yourself. This is a fantastic little CodePen demo (written in JavaScript, naturally) and should put a smile on your face 😁 Thanks to Greg Hovanesyan for this!        

Published by [Cooperpress](https://cooperpress.com/) and edited by [Peter Cooper](https://twitter.com/peterc) 

'JavaScript' is a trademark of Oracle Corporation in the US
We are not endorsed by or affiliated with Oracle. 

[Change your email address](https://javascriptweekly.com/edit_subscription/*|UID|*) or [stop getting this newsletter](https://javascriptweekly.com/leave/*|UID|*). 

© Cooper Press Ltd · Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom
