Skip to content

Conversation

liamcmitchell
Copy link
Contributor

@liamcmitchell liamcmitchell commented Jan 2, 2025

Main improvement is reducing the layout shift caused by the sidebar popping in on page load.

  • Set sidebar state & width in inline_html.js
  • Reduce sidebar state & animation classes from 6 to 2
  • Remove redundant body selectors
  • Add max width to drawer
  • Refactor sidebar-drawer.js to reduce indirection and simplify logic
  • Register sidebar size observer on mousedown to avoid recording non-user changes and triggering DOM updates
  • Simplify sidebar animation sequence reducing DOM updates and callbacks
  • Refactor theme.js
  • Remove toast on browser theme change (it made the code cleaner and I thought it was OK to go)
  • Change script tags to defer - this removes the need for onDocumentReady helper but I thought I would stop my refactoring here

My machine is too old to capture accurate video of page load so instead I'm showing page load recordings from Chrome devtools performance tab.

Before

Screen.Recording.2025-01-02.at.08.47.06.mov

After

Screen.Recording.2025-01-02.at.08.49.20.mov

Biggest layout shift is now 0.4 instead of 0.9, page loads a little faster, assets are a little smaller.

@josevalim
Copy link
Member

This looks great @liamcmitchell! I found only one regression. On small screens, the hamburger for opening and closing the sidebar is moving with the page, instead of remaining static. You can see it it is out of place in the screenshot below:

Screenshot 2025-01-02 at 09 45 47

If you scroll further, then it fully disappears!

@liamcmitchell
Copy link
Contributor Author

Sorry, didn't check other stylesheets for the classes I removed.

Fixed this and a few other issues.

@josevalim josevalim merged commit e6f7ceb into elixir-lang:main Jan 2, 2025
5 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@liamcmitchell liamcmitchell deleted the assets branch January 2, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants