Skip to content

Commit 2d94bc4

Browse files
Make non-pro dummy app use deferred scripts only (fixes race conditions while hydrating components there) (#1991)
1 parent 6c2b0a9 commit 2d94bc4

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

spec/dummy/app/controllers/application_controller.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,4 @@ class ApplicationController < ActionController::Base
1919
redirect_to server_side_log_throw_raise_invoker_path,
2020
flash: { error: msg }
2121
end
22-
23-
helper_method :uses_redux_shared_store?
24-
25-
# Returns true if the current page uses Redux shared stores with inline registration
26-
# These pages require defer: true instead of async: true for proper script execution order
27-
def uses_redux_shared_store?
28-
# Pages that use redux_store helper with inline component registration
29-
action_name.in?(%w[
30-
index
31-
server_side_redux_app
32-
server_side_redux_app_cached
33-
server_side_hello_world_shared_store
34-
server_side_hello_world_shared_store_defer
35-
server_side_hello_world_shared_store_controller
36-
client_side_hello_world_shared_store
37-
client_side_hello_world_shared_store_defer
38-
client_side_hello_world_shared_store_controller
39-
])
40-
end
4122
end

spec/dummy/app/views/layouts/application.html.erb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99

1010
<%= yield :head %>
1111

12-
<%# Conditionally use defer: true for pages with Redux shared stores (inline registration).
13-
Modern apps should use async: true for optimal performance. See docs for details:
14-
docs/building-features/streaming-server-rendering.md %>
15-
<% if uses_redux_shared_store? %>
16-
<%# defer: true required for Redux shared stores with inline component registration %>
17-
<%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: true) %>
18-
<% else %>
19-
<%# async: true is the recommended approach for modern apps (Shakapacker >= 8.2.0) %>
20-
<%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', async: true) %>
21-
<% end %>
12+
<%= javascript_pack_tag('client-bundle', 'data-turbo-track': 'reload', defer: true) %>
2213

2314
<%= csrf_meta_tags %>
2415
</head>

0 commit comments

Comments
 (0)