Snippets about webdev
9 snippets
-
SNP 143
#46B
Trusted certificates for localhost with mkcert
HTTPS on your dev server without the browser warning, in three commands.
-
SNP 118
#639
Lazy load images without JavaScript
Two attributes and the browser handles it.
-
SNP 107
#149
Open external links in a new tab the right way
What target="_blank" needs next to it, and whether it needs anything anymore.
-
SNP 072
#935
Do something when an element scrolls into view
Lazy loading, fade-ins and "read" markers without a scroll listener.
-
SNP 052
#25A
Fetch with a timeout
fetch() waits forever by default. Give up after a few seconds.
-
SNP 045
#164
Respect prefers-reduced-motion
Some people get dizzy from your fancy animations. The browser tells you who, so listen.
-
SNP 031
#592
Copy text to the clipboard
The modern clipboard API in three lines, with the gotchas.
-
SNP 022
#B31
Debounce a function in plain JavaScript
Run a function only after the user stopped typing, without pulling in a library for it.
-
SNP 015
#B96
Create timeout in an async function
To throttle the execution of our async function we will create a timeout method.