Snippets about webdev

9 snippets

Back to all snippets

  1. SNP143

    Trusted certificates for localhost with mkcert

    HTTPS on your dev server without the browser warning, in three commands.

    8 lines of sh and js in 2 blocks, 10 lines of explanation.

    #46B ssl webdev cmd
  2. SNP118

    Lazy load images without JavaScript

    Two attributes and the browser handles it.

    2 lines of html in 2 blocks, 7 lines of explanation.

    #639 html webdev
  3. SNP107

    Open external links in a new tab the right way

    What target="_blank" needs next to it, and whether it needs anything anymore.

    4 lines of html in 2 blocks, 6 lines of explanation.

    #149 html webdev
  4. SNP072

    Do something when an element scrolls into view

    Lazy loading, fade-ins and "read" markers without a scroll listener.

    12 lines of js in 1 block, 7 lines of explanation.

    #935 js webdev
  5. SNP052

    Fetch with a timeout

    fetch() waits forever by default. Give up after a few seconds.

    6 lines of js in 2 blocks, 4 lines of explanation.

    #25A js webdev
  6. SNP045

    Respect prefers-reduced-motion

    Some people get dizzy from your fancy animations. The browser tells you who, so listen.

    10 lines of css and js in 2 blocks, 6 lines of explanation.

    #164 css a11y webdev
  7. SNP031

    Copy text to the clipboard

    The modern clipboard API in three lines, with the gotchas.

    8 lines of js in 2 blocks, 5 lines of explanation.

    #592 js webdev
  8. SNP022

    Debounce a function in plain JavaScript

    Run a function only after the user stopped typing, without pulling in a library for it.

    10 lines of js in 2 blocks, 5 lines of explanation.

    #B31 js webdev
  9. SNP015

    Create timeout in an async function

    To throttle the execution of our async function we will create a timeout method.

    4 lines of js in 2 blocks, 4 lines of explanation.

    #B96 webdev js