Skip to content

Instantly share code, notes, and snippets.

@rchytas
Forked from hofmannsven/README.md
Created May 15, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchytas/5efcbc1b73c94ee6a06ebc23bfbcf561 to your computer and use it in GitHub Desktop.
Save rchytas/5efcbc1b73c94ee6a06ebc23bfbcf561 to your computer and use it in GitHub Desktop.
Notes on frontend performance

Frontend Performance

Notes & tips

  • Reflow (Mozilla) = Layout (Webkit)
  • Loading: Layout > Paint > Composition
  • Composition is on GPU like translate > skips layout and paint loading cycle
  • Aim for 60 FPS
  • Only change properties that trigger compositing rather than layout or paint
  • Use requestAnimationFrame
  • Batch edit CSS via JS: all changes at once or change CSS class name
  • Change CSS class name instead of single attributes
  • Hide elements with display: none, make changes, display again to skip layout and repaint
  • Use transform + opacity to skip layout and repaint
  • Shadow and blur is bad for scroll performance

Recording tips

  • Keep recordings as short as possible
  • Avoid unnecessary actions (like clicks,...)
  • Disable the browser cache
  • Disable all browser extensions (or use incognito mode)

Developer tools

  • Tab: Timeline
  • Tab Preferences: More tools » Rendering settings » Enable paint flashing
  • Tab Preferences: More tools » Rendering settings » Show FPS meter
  • Tab: Performance

Open Firefox ProfileManager

/Applications/Firefox.app/Contents/MacOS/firefox-bin -ProfileManager

Taking screenshots: screenshot --fullpage

Further reading

Check for JavaScript

<script type="text/javascript">
  document.documentElement.className = 'js';
</script>

Testing/Demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment