Skip to content

Commit 9121184

Browse files
jeffnappijustin808
authored andcommitted
Place the rendered output before the spec tag (#1047)
Many folks using the SSR features of react-on-rails are doing so in order to improve SEO while simultaneously improving user experience. It is commonly recommended to have key content rendered into the HTML at the earliest possible point. From what I understand, there is no need for the specification tag/script to come before the rendered content and simply swapping the order can have a significant impact on the content that fits within the 100kb "SEO optimized" page size. e.g. if I have 50kb of state data followed by 100kb of the actual rendered HTML, the bottom half of the page may not get indexed by e.g. Google.
1 parent 9451a4f commit 9121184

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/helpers/react_on_rails_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ def compose_react_component_html_with_spec_and_console(component_specification_t
305305
# IMPORTANT: Ensure that we mark string as html_safe to avoid escaping.
306306
# rubocop:disable Layout/IndentHeredoc
307307
<<-HTML.html_safe
308+
#{rendered_output}
308309
#{component_specification_tag}
309-
#{rendered_output}
310-
#{console_script}
310+
#{console_script}
311311
HTML
312312
# rubocop:enable Layout/IndentHeredoc
313313
end

0 commit comments

Comments
 (0)