Skip to content

Commit

Permalink
Preload decorate.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mokimo committed Sep 16, 2024
1 parent abf351f commit a555eda
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,16 @@ export async function loadBlock(block) {
const base = miloLibs && MILO_BLOCKS.includes(name) ? miloLibs : codeRoot;
let path = `${base}/blocks/${name}`;

if (name === 'marquee' || name === 'hero-marquee') {
loadLink(`${base}/utils/decorate.js`, { rel: 'preload', as: 'script', crossorigin: 'anonymous' });
}
if (mep?.blocks?.[name]) path = mep.blocks[name];

const blockPath = `${path}/${name}`;

const styleLoaded = hasStyles && new Promise((resolve) => {
loadStyle(`${blockPath}.css`, resolve);
});

const scriptLoaded = new Promise((resolve) => {
(async () => {
try {
Expand Down Expand Up @@ -1238,9 +1240,6 @@ async function processSection(section, config, isDoc) {
decoratePlaceholders(section.el, config),
decorateIcons(section.el, config),
];
if (section.classList.contains('marquee') || section.classList.contains('hero-marquee')) {
loadLink('./utils/decorate.js', { rel: 'preload', as: 'script', crossorigin: 'anonymous' });
}
if (section.preloadLinks.length) {
const [modals, nonModals] = partition(section.preloadLinks, (block) => block.classList.contains('modal'));
nonModals.forEach((block) => tasks.push(loadBlock(block)));
Expand Down

0 comments on commit a555eda

Please sign in to comment.