Skip to content

Commit

Permalink
Defer configuration until the script is loaded
Browse files Browse the repository at this point in the history
This is critical when using module based javascript, because the inline scripts occur ahead of deferred scripts. All module scripts are deferred by default. Script tags without a src attribute can not be deferred.
  • Loading branch information
jcoyne committed Feb 22, 2023
1 parent 11c9336 commit 128fb68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/layouts/spotlight/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<%= description %>
<%= twitter_card %>
<%= opengraph %>
<%= javascript_tag "Spotlight.sirTrevorIcon = '#{asset_path('spotlight/blocks/sir-trevor-icons.svg')}'" %>
<%= javascript_tag "window.addEventListener('load', () => Spotlight.sirTrevorIcon = '#{asset_path('spotlight/blocks/sir-trevor-icons.svg')}')" %>
<%= javascript_tag '$.fx.off = true;' if Rails.env.test? %>
</head>
<body class="<%= render_body_class %>">
Expand Down

0 comments on commit 128fb68

Please sign in to comment.