Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web App Performance Optimization

Web App Performance Optimization

Web App Performance Optimization at EarnIn

Siwat Kaolueng

February 04, 2025
Tweet

More Decks by Siwat Kaolueng

Other Decks in Technology

Transcript

  1. • 9 Months ago • Metrics - Web Vitals •

    Tools • Solution ◦ Explicit import ◦ Fix some Libraries ◦ Lazy load scripts as much as possible ▪ 1st Party ▪ 3rd Party ◦ Offload 3rd Party Script ◦ Partytown • Results • TODOs 6 web-app-frontend Agenda
  2. • Represents metric measures the time from when the user

    first navigated to the page to when any part of the page's content is rendered on the screen. 13 web-app-frontend First Contentful Paint FCP
  3. • Represents how quickly the main content of a web

    page is loaded. Specifically, LCP measures the time from when the user initiates loading the page until the largest image or text block is rendered within the viewport. • To provide a good user experience, sites should strive to have an LCP of 2.5 seconds or less for at least 75% of page visits. 14 web-app-frontend Largest Contentful Paint LCP
  4. • The metric measures the total amount of time after

    First Contentful Paint FCP) where the main thread was blocked for long enough to prevent input responsiveness. • To provide a good user experience, sites should strive to have a Total Blocking Time of less than 200 milliseconds when tested on average mobile hardware. 15 web-app-frontend Total Blocking Time TBT
  5. Chrome for Developers on X "A better way to measure

    interaction responsiveness is coming to Core Web Vitals! On March 12 Interaction to Next Paint INP) will become one of the three essential metrics to delivering great UX on the web Start here to learn more and get prepared 👇 https://t.co/wtmVzhHP0l" / X (twitter.com)
  6. • Use headless mode to not include predefined runtime CSS-in-JS(goober)

    • Donʼt use runtime CSS-in-JS 39 web-app-frontend Fix react-hot-toast
  7. 40 web-app-frontend Datadog RUM is large Browser library bundle size

    is very large. · Issue #317 · DataDog/browser-sdk (github.com)
  8. • The web app must be eager load only necessary

    resources that it use on that page and load other resources later (lazy). Not all users have the super fast speed network. 44 web-app-frontend Lazy loading
  9. 1st Party Scripts🥇 web-app-frontend - Our code base that is

    our main functionality - We mostly control loading behavior - Lazy loading by Page level Routes, Component Level
  10. 3rd Party Scripts🥉 web-app-frontend - Third-party JavaScript often refers to

    scripts that can be embedded into any site directly from a third-party vendor. These scripts can include ads, analytics, widgets and other scripts that make the web more dynamic and interactive. - Examples of third-party scripts include: - Analytics & metrics scripts - A/B testing scripts for experiments - Helper libraries (such as date formatting, animation, or functional libraries)
  11. • Segment.js also eager load other 3rd party libraries such

    as Adword, Facebook Pixel • Luckily, Segment.js provided the lazy load other 3rd party libraries 50 web-app-frontend Lazy load Segment and its friends
  12. • At the beginning of starting the web application, we

    use Recaptcha to prevent bots • It takes a time to load 52 web-app-frontend Lazy load Recaptcha
  13. 55 web-app-frontend Adam Bradley ⚡ on X: "Quick diagram of

    how Partytown is able to have a blocking call in the web worker, but still asynchronously send/received data between threads https://t.co/A5wiZrNGmr" / X (twitter.com)
  14. Impact: Reduce page load time 1 second 64 web-app-frontend All

    pages 1s Login page 3s Questionnaire 1s
  15. • Configure crossOriginIsolated header Partytown to use Atomics 10x faster

    communication between threads compare to the service-worker requests) • Find a way to offload Datadog RUM from the main thread • Replace Form library (zod) to smaller alternative (valibot) • Fix "request waterfall problem" of Module Federation with prefetch • Inline Critical CSS Tailwind • … 68 web-app-frontend TODOs