Snippets about webdev

9 snippets

Back to all snippets

  1. SNP 143 #46B

    Trusted certificates for localhost with mkcert

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

  2. SNP 118 #639

    Lazy load images without JavaScript

    Two attributes and the browser handles it.

  3. 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.

  4. SNP 072 #935

    Do something when an element scrolls into view

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

  5. SNP 052 #25A

    Fetch with a timeout

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

  6. SNP 045 #164

    Respect prefers-reduced-motion

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

  7. SNP 031 #592

    Copy text to the clipboard

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

  8. 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.

  9. SNP 015 #B96

    Create timeout in an async function

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