Tips, Tricks, Best Practices

for front-end development

Accept any numbers of parameters

JavaScript

Access local webpack dev servers from external devices

Webpack

Access the selected node in the Console

DevTools

Add a line break between inline elements

CSS

Add a subject to a mailto link

HTML

Add an icon to external links

CSS

Add keyboard shortcuts

HTML

Always pass the radix to parseInt

JavaScript

Always put the footer at the bottom

CSS

Always use "noopener" or "noreferrer" for links opened in new tabs

HTML

Append leading zeros to ordered list items

CSS

Avoid boolean parameters

JavaScript

Avoid invisible text when loading a font

CSS, Google Font

Avoid skipping heading levels

Accessibility, HTML

Avoid to use colons and periods in the id attribute

DOM, HTML

Avoid using CSS @import

CSS

Avoid using multiple <h1> tags per page

HTML

Avoid using the <b>, <i>, <s> and <u> tags

Accessibility, HTML

Capture a screenshot without shadow on macOS

macOS

Center an element vertically and horizontally

CSS

Check if the browser supports for an element attribute

DOM, JavaScript

Checkout the previous branch

Git

Combine Google font requests

CSS, Google Font

Combine styles with the :is pseudo-class selector

CSS

Compose multiple React providers

React

Conditional logging in the Console

DevTools

Convert string to number

JavaScript

Copy a long variable from the Console

DevTools

Copy screenshots to the clipboard on macOS

macOS

Copy the base64 data of an image

DevTools

Copy the full path of a file on macOS

macOS

Create a big file on Linux

Command Line

Create a custom emoji cursor

CSS

Create a descending list of numbered items

HTML

Create a download link

HTML

Create a file of any size

macOS

Create a function that accepts a single parameter

JavaScript

Create a line-on-sides heading

CSS

Create a multiline strings

JavaScript

Create a polyfill

JavaScript

Create an array with conditional elements

JavaScript

Create an autocomplete list with the datalist element

HTML

Create an object with dynamic keys

JavaScript

Create an one-time event handler

DOM, JavaScript

Create shapes with the clip path property

CSS

Display links in the print mode

CSS

Do not add custom methods to primitive objects

JavaScript

Don't mix styles of an element with its container

CSS

Do not use magic numbers when manipulating strings

JavaScript

Do not use submit to name a submit button

HTML

Early return

JavaScript

Enforce required parameters

JavaScript

Escape CSS class names

CSS

Filter file types of a file input

HTML

Find scrollable elements

Firefox DevTools

Find the root NPM package to update

NPM

Fold CSS declarations with region markers

CSS, Visual Studio Code

Force the browsers to download new favicon

HTML

Format a list

JavaScript

Format a number as a currency string

JavaScript

Get characters of a string

JavaScript

Get rid of escaping quotes with template literal

JavaScript

Get the current timestamp

JavaScript

Go to the previous directory

Command Line

Hide an element with Chrome DevTools

DevTools

Highlight text with the mark element

HTML

Ignore case sensitivity in a CSS attribute selector

CSS

Ignore items from array destructuring

JavaScript

Increase or decrease CSS values with Chrome DevTools

DevTools

Indicate img elements that miss alt attribute

A11y, Accessibility, CSS

Inspect an element shown on hover

DevTools

Keep the calculation of a magic number

JavaScript

Lazy loading images with the loading attribute

HTML

List branches sorted by most recent commit date

Git

Load given characters in a Google font request

CSS, Google Font

Locate an element with a given selector

DevTools

Log a value to the Console

JavaScript

Log a variable in an arrow function

JavaScript

Log a variable to the console using conditional breakpoints

DevTools

Log an array to the Console

JavaScript

Log the full object in NodeJS

NodeJS

Make a table with equal column widths

CSS

Manage multiple boolean flags

JavaScript

Merge different arrays

JavaScript

Move the cursor to any position in a macOS command

Command Line, macOS

Move the screenshot area on macOS

macOS

Number headings and subheadings automatically

CSS

Omit properties of a Svelte component

Svelte

Omit values of HTML boolean attributes

HTML

Open a package's homepage or repo

NPM

Open all links in new tabs

HTML

Override the behavior of instanceof

JavaScript

Pass an array as function arguments

JavaScript

Persist Console logs between page refreshes

DevTools

Pick given properties from a JSON representation

JavaScript

Pick the first and last items of an array

JavaScript

Prefix class name with js to manipulate with javascript

DOM, HTML

Pretty format JSON

JavaScript

Prevent a string from being escaped

JavaScript

Prevent anchor links from disappearing behind a sticky header

CSS

Prevent browsers from asking to translate

HTML

Prevent macOS from going to sleep

macOS

Prevent the default behavior with jQuery event handler

DOM, JavaScript

Pure collapsible element

HTML

Put special operators at the beginning of a function

JavaScript

Quick query elements in the Console

DevTools

Quickly type color variables

Visual Studio Code

Remove a property from an object

JavaScript

Remove the border from the last navigation item

CSS

Replace multiple if statements with a lookup table

JavaScript

Replace multiple if statements with a single switch statement

JavaScript

Return an object in an arrow function quickly

JavaScript

Reuse the current color

CSS

Run the last command as the root user

Command Line

Save a few bytes when checking the existence of module

JavaScript

Separate list items

CSS

Set content for an empty link

CSS

Share recommendation Visual Studio Code extensions

Visual Studio Code

Shorten codes with the comma operator

JavaScript

Shorten import paths in TypeScript

TypeScript

Shorten import paths in Webpack

Webpack

Show a placeholder for an empty list

CSS

Show the first letter only

CSS

Skip questions when creating a package.json file

NPM

Smooth scrolling with pure CSS

CSS

Specify the doctype

HTML

Start a simple web server on macOS

macOS

Style broken images

CSS

Style index numbers of list items

CSS

Style list items with special characters

CSS

Swap two variables

JavaScript

Toggle hidden files on macOS

macOS

Track the focused element with Chrome DevTools

DevTools

Transform values from a JSON representation

JavaScript

Trim the spaces before parsing a number

JavaScript

Truncate long text

CSS

Unpack a property of an object with different name

JavaScript

Use an underscore to name unused argument

JavaScript

Use Array.includes for multiple conditionals

JavaScript

Use CSS fallback properties

CSS

Use DocumentFragments when adding a big list of elements

DOM, JavaScript

Use multiple SSH keys for different GitHub accounts

Git

Use negative nth-child and nth-last-child

CSS

Use short-circuits conditionals

JavaScript

Use string literals for the TypeScript enum values

TypeScript

Use template literal to concatenate strings

JavaScript

Use the datetime attribute when displaying dates, times

HTML

Use the strict equality operator when comparing variables

JavaScript

Use the wbr tags to represent path

HTML

Use underscores to represent a number

JavaScript

Validate an input value with the pattern attribute

HTML

View a file in a different branch without switching the branch

Git

View print stylesheets with Chrome DevTools

DevTools

Visualize elements on page with the outline style

DOM, JavaScript

Watch a variable's value with live expressions

DevTools

Wrap arrow function body in parentheses

JavaScript

Write CSS rules for Firefox only

CSS