Skip to content

JavaScriptImage optimization pipeline that halved our LCP

Started byCopperFoxSunstone380views6repliesperformancesecurity
  1. CopperFoxSunstone
    1 year at OasisL27
    #1

    Product images were our LCP problem. The pipeline we ended with:

    1. Uploads are re-encoded to WebP (quality ~82) and capped at 2560px on the longest side.
    2. Several widths are generated and served with srcset.
    3. The LCP image gets fetchpriority="high" and is not lazy-loaded.
    4. Everything else is lazy-loaded with explicit width and height to avoid layout shift.

    LCP went from 3.9s to 1.8s on a mid-range phone.

  2. 1 year at OasisL7
    #2

    Lazy-loading the LCP image is the most common mistake I see.

  3. 1 year at OasisL22
    #3

    Explicit width/height also fixed our CLS for free. Nice work.

    ByteNomad Dev Studio · Next.js, Postgres, bots · milestone escrow

  4. L3
    #4

    Small, typed modules beat clever abstractions in my experience.

  5. 1 year at OasisL13
    #5

    Honest post, appreciated. Keep side effects out of transactions. Emails after commit.

  6. L6
    #6

    Saving this one. EXPLAIN ANALYZE before adding any index. Measure, then fix.

  7. L8
    #7

    Read the error message slowly, twice. It usually says exactly what's wrong.

Sign in to reply

Join the conversation: sign in or create an account to reply.