Skip to content

Commit

Permalink
Remove references to partytown. (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
bstopp authored and Brendan Robert committed Jan 10, 2024
1 parent 9c727f8 commit e2e13cd
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 68 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
helix-importer-ui
scripts/partytown
7 changes: 1 addition & 6 deletions blocks/hero/search/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import {
function observeForm() {
const script = document.createElement('script');
script.type = 'module';
script.innerHTML = `
const script = document.createElement('script');
script.type = 'module';
script.src = '${window.hlx.codeBasePath}/blocks/hero/search/home-delayed.js';
document.head.append(script);
`;
script.src = `${window.hlx.codeBasePath}/blocks/hero/search/home-delayed.js`;
document.head.append(script);
}

Expand Down
31 changes: 4 additions & 27 deletions blocks/liveby-map/liveby-map-delayed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global google */

import { fetchPlaceholders } from '../../scripts/aem.js';
import loadMaps from '../../scripts/google-maps/index.js';

function getCenter(coords) {
// Find bounding box
Expand Down Expand Up @@ -53,28 +52,6 @@ function initLiveByMap() {
const poly = new google.maps.Polygon(polyOptions);
}

function loadJS(src) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.defer = true;
script.innerHTML = `
(()=>{
let script = document.createElement('script');
script.src = '${src}';
document.head.append(script);
})();
`;
document.head.append(script);
}

async function initGoogleMapsAPI() {
const placeholders = await fetchPlaceholders();
const CALLBACK_FN = 'initLiveByMap';
window[CALLBACK_FN] = initLiveByMap;
const { mapsApiKey } = placeholders;
const src = `https://maps.googleapis.com/maps/api/js?key=${mapsApiKey}&libraries=maps&callback=${CALLBACK_FN}`;
loadJS(src);
}

initGoogleMapsAPI();
loadMaps();
await window.google.maps.importLibrary('maps');
initLiveByMap();
13 changes: 4 additions & 9 deletions blocks/liveby-map/liveby-map.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
let alreadyDeferred = false;
function initGoogleMapsAPI() {
function initMap() {
if (alreadyDeferred) {
return;
}
alreadyDeferred = true;
const script = document.createElement('script');
script.type = 'text/partytown';
script.innerHTML = `
const script = document.createElement('script');
script.type = 'module';
script.src = '${window.hlx.codeBasePath}/blocks/liveby-map/liveby-map-delayed.js';
document.head.append(script);
`;
script.type = 'module';
script.src = `${window.hlx.codeBasePath}/blocks/liveby-map/liveby-map-delayed.js`;
document.head.append(script);
}

export default async function decorate(block) {
const map = document.createElement('div');
map.classList.add('liveby-map-main');
block.replaceChildren(map);
initGoogleMapsAPI();
window.setTimeout(initMap, 3000);
}
12 changes: 3 additions & 9 deletions blocks/quote-carousel/quote-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ function observeCarousel() {
if (alreadyDeferred) {
return;
}

alreadyDeferred = true;
const script = document.createElement('script');
script.type = 'text/partytown';
script.innerHTML = `
const script = document.createElement('script');
script.type = 'module';
script.src = '${window.hlx.codeBasePath}/blocks/quote-carousel/quote-carousel-delayed.js';
document.head.append(script);
`;
script.type = 'module';
script.src = `${window.hlx.codeBasePath}/blocks/quote-carousel/quote-carousel-delayed.js`;
document.head.append(script);
}

Expand Down Expand Up @@ -94,6 +88,6 @@ export default async function decorate(block) {
</div>
<button name="next" aria-label="Next" class="control-button"><svg><use xlink:href="/icons/icons.svg#carrot"/></svg></button>
`;
observeCarousel();
window.setTimeout(observeCarousel, 3000);
}
}
2 changes: 0 additions & 2 deletions scripts/partytown/partytown-atomics.js

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/partytown/partytown-media.js

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/partytown/partytown-sw.js

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/partytown/partytown.js

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,6 @@ export function addFavIcon(href) {
}
}

function initPartytown() {
window.partytown = {
lib: '/scripts/partytown/',
};
import('./partytown/partytown.js');
}

/**
* Load the login block to the main body.
*
Expand Down Expand Up @@ -336,7 +329,6 @@ async function loadLazy(doc) {
sampleRUM('lazy');
sampleRUM.observe(main.querySelectorAll('div[data-block-name]'));
sampleRUM.observe(main.querySelectorAll('picture > img'));
initPartytown();
}

/**
Expand Down

0 comments on commit e2e13cd

Please sign in to comment.