There's a console warning about Turbo being loaded from within the <body> element instead of the <head>.
Conflicting requirements between three systems:
- Turbo - Wants to be loaded in
<head>to avoid re-evaluation on page changes - Shakapacker - Requires all
append_javascript_pack_tagcalls to happen before the finaljavascript_pack_tag - React on Rails - The
react_componenthelper internally callsappend_javascript_pack_tagwhen rendering components in the body
- Moving
javascript_pack_tagto head - Breaks becausereact_componentcalls come after it - Using
data-turbo-suppress-warning- Doesn't properly suppress the warning
- Extract Turbo into a separate pack from stimulus-bundle and load it in the head
- Use
prepend_javascript_pack_taginstead ofappendfor component registration - Configure React on Rails v16 to use a different component loading strategy
- Investigate if the auto-registration feature has a different recommended pack loading pattern
The application works correctly with the pack tags at the end of the body. The Turbo warning is cosmetic and doesn't affect functionality.
- PR #649: Initial v16 migration
- Shakapacker docs: https://github.com/shakacode/shakapacker#view-helper-append_javascript_pack_tag
- Turbo docs: https://turbo.hotwired.dev/handbook/building#working-with-script-elements
- React on Rails v16 docs: https://www.shakacode.com/react-on-rails/docs/