Skip to content

Commit

Permalink
Never load Google Maps API twice (fixed personal heatmap)
Browse files Browse the repository at this point in the history
Fixes: #13
  • Loading branch information
liskin committed Jun 6, 2020
1 parent 1a474f9 commit 4988edb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions load.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@
document.body.appendChild(s);
});

Promise.resolve(window.jQuery ? null
: getScript("https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js").then(() => jQuery.noConflict())
).then(() => Promise.all([
const loadJQuery = () => window.jQuery
? Promise.resolve(null)
: getScript("https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js").then(() => jQuery.noConflict());
const loadGoogleMaps = () => document.querySelector('script[src*="//maps.google.com/maps/api/js"]')
? Promise.resolve(null)
: ignoreError(getScript("https://maps.google.com/maps/api/js?sensor=true&client=gme-stravainc1"));
const loadGoogleLeaflet = () => (window.L && window.L.Class)
? getScript(getURL('Google.js'))
: Promise.resolve(null);

loadJQuery().then(() => Promise.all([
getScript(getURL('arrive.min.js')),
getScript(getURL('layers.js')),
getScript(getURL('donation.js')),
ignoreError(getScript("https://maps.google.com/maps/api/js?sensor=true&client=gme-stravainc1")).then(
() => getScript(getURL('Google.js'))),
loadGoogleMaps().then(() => loadGoogleLeaflet()),
])).then(function () {
getScript(getURL('fix.js'));
getScript(getURL('fix-mapbox.js'));
Expand Down

0 comments on commit 4988edb

Please sign in to comment.