Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove references to partytown. #178

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}

/**
* Loads everything that doesn't need to be delayed.
* @param {Element} doc The container element
Expand All @@ -321,7 +314,6 @@ async function loadLazy(doc) {
sampleRUM('lazy');
sampleRUM.observe(main.querySelectorAll('div[data-block-name]'));
sampleRUM.observe(main.querySelectorAll('picture > img'));
initPartytown();
}

/**
Expand Down