Only load Google Maps JS where it's actually needed

This commit is contained in:
Matt-Yorkley
2021-08-16 13:37:36 +01:00
parent a98e4417c0
commit 744bd9d1be
7 changed files with 18 additions and 4 deletions

View File

@@ -5,6 +5,9 @@
- content_for(:image) do
= @group.logo.url
- content_for :scripts do
= render partial: "shared/google_maps_js"
- content_for :injection_data do
= inject_available_countries
= inject_group_enterprises

View File

@@ -42,13 +42,10 @@
- if Spree::Config.stripe_connect_enabled
= render "shared/stripe_js"
- if !ContentConfig.open_street_map_enabled
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places,geometry#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''} "}
= javascript_include_tag "darkswarm/all"
= javascript_include_tag "web/all"
= render "layouts/i18n_script"
= yield :scripts
= inject_current_hub

View File

@@ -1,6 +1,9 @@
- content_for(:title) do
= t :map_title
- content_for :scripts do
= render partial: "shared/google_maps_js"
- content_for :injection_data do
= inject_available_countries
= inject_enterprise_shopfront_list

View File

@@ -1,6 +1,9 @@
- content_for(:title) do
= t :producers_title
- content_for :scripts do
= render partial: "shared/google_maps_js"
- content_for :injection_data do
- cache @enterprises do
= inject_enterprises(@enterprises)

View File

@@ -1,6 +1,9 @@
- content_for(:title) do
= t :register_title
- content_for :scripts do
= render partial: "shared/google_maps_js"
- content_for :injection_data do
= inject_spree_api_key
= inject_available_countries

View File

@@ -0,0 +1,2 @@
- if !ContentConfig.open_street_map_enabled
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places,geometry#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''} "}

View File

@@ -1,6 +1,9 @@
- content_for(:title) do
= t :shops_title
- content_for :scripts do
= render partial: "shared/google_maps_js"
- content_for :injection_data do
- cache(*CacheService::FragmentCaching.ams_shops) do
= inject_enterprises(@enterprises)