<% content_for :javascript do %>
  <script type="text/javascript">
    var eventName = typeof(Turbolinks) !== 'undefined' ? 'page:change' : 'DOMContentLoaded';

    document.addEventListener(eventName, function() {
      <% if flash[:notice] %>
        ShopifyApp.flashNotice("<%= j flash[:notice].html_safe %>");
      <% end %>

      <% if flash[:error] %>
        ShopifyApp.flashError("<%= j flash[:error].html_safe %>");
      <% end %>
    });
  </script>
<% end %>

<% content_for :javascript do %>
  <script type="text/javascript">
    var eventName = typeof(Turbolinks) !== 'undefined' ? 'page:change' : 'DOMContentLoaded';

    document.addEventListener(eventName, function() {
      <% if flash[:notice] %>
        ShopifyApp.flashNotice("<%= escape_javascript flash[:notice].html_safe %>");
      <% end %>

      <% if flash[:error] %>
        ShopifyApp.flashError("<%= escape_javascript flash[:error].html_safe %>");
      <% end %>
    });
  </script>
<% end %>

Use more obvious method name
Use more obvious method name
