If you're using Trix (Rails' WYSIWYG editor), you're probably loading half a megabyte of JS... even when your users don't need it! 😱
The problem: Action Text loads Trix on FIRST page load, The impact: On weak 4G? It's a disaster 📱💔
My dead-simple solution: ✅ Disable preload in importmap.rb ✅ Load Trix only when a form actually needs it ✅ A tiny 10-line Turbo helper
Bonus: I even eliminated the layout shift that makes the page jump! 🎯
The crazy part? Rails makes adding a rich text editor SO simple (literally 3 minutes) that we often forget to optimize the loading 😅
👉 Full article with code: https://en.developpeur-freelance.io/trix-asynchronously/
(Also available in french)
(Also available in french)