Skip to content
Maxim Orlov Logo

Helping Node.js developers write robust applications 🚀

💡 Handy Tips

A collection of 111 tips that come in real handy when you need them. Originally posted as tweets on my Twitter account, and now gathered here so you can browse them easily.

Copyright Format in Website Footer

💡 Copyright in the website footer, how do you format it?

👉🏼 <copy> <date> <author>

<copy> - Copyright, Copr. or ©
<date> - Years of publication, e.g. 2019-2021 or 2021
<author> - Name or Company name

I use: Copyright 2019-2021 Maxim Orlov

Debug Srcset and Sizes Attributes in Images

💡 Working with srcset and sizes and looking for easier debugging of what the browser does?

👉🏼 Import responsive-image-test by @OliverJAsh and hook it up to your image. It will console computed and real widths for you to compare. ✨

Importing responsive-image-test from unpkg and hooking it to an image with observeSizes function.

Using HTML Tags in Markdown

💡 Using *aside* tag in Markdown for (side-)notes in articles?

👉🏼 Make sure to add an empty line between the tag and the content to have it rendered in Markdown instead of raw HTML.

Two examples of markdown content inside an aside HTML tag surrounded with, and without, empty lines. Two examples showing raw formatted content, and content parsed as markdown.

Support ESM and CommonJS Uses of Your Library

💡 Writing a Node.js library using ES Modules instead of Common JS?

👉🏼 Support users who aren't using ESM by adding a mapping for the main export for your library in your package.json file.

Support ESM and CommonJS by setting exports[.].import for ESM and exports[.].require for CommonJS in package.json of your library.

Using ES Modules in Node.js

💡 In Node.js, you can use native ES Modules in two ways:

👉🏼 By using the ".mjs" extension or adding "type": "module" to your package.json.

❗️ Available from Node.js 13.2 and up.

Two ways to use ESM: 1. Use .mjs file extension, or 2. Add type: module to your package.json.