Skip to content

Commit

Permalink
MWPW-149124 Improve Focus Page for Performance Improvement Tiger Team (
Browse files Browse the repository at this point in the history
…#2391)

* Optimize icons  .css and .svg loading

* Preload helpers.js

* Remove dependency on helpers.js
  • Loading branch information
TsayAdobe authored Jul 16, 2024
1 parent fc03376 commit f160c4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions libs/features/icons/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ let fetched = false;
async function getSVGsfromFile(path) {
/* c8 ignore next */
if (!path) return null;
const { customFetch } = await import('../../utils/helpers.js');
const resp = await customFetch({ resource: path, withCacheRules: true })
.catch(() => ({}));
const resp = await fetch(path);
/* c8 ignore next */
if (!resp.ok) return null;
const miloIcons = {};
Expand Down
6 changes: 3 additions & 3 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ function decorateHeader() {
async function decorateIcons(area, config) {
const icons = area.querySelectorAll('span.icon');
if (icons.length === 0) return;
const { miloLibs, codeRoot } = config;
const base = miloLibs || codeRoot;
await new Promise((resolve) => { loadStyle(`${base}/features/icons/icons.css`, resolve); });
const { base } = config;
loadStyle(`${base}/features/icons/icons.css`);
loadLink(`${base}/img/icons/icons.svg`, { rel: 'preload', as: 'fetch', crossorigin: 'anonymous' });
const { default: loadIcons } = await import('../features/icons/icons.js');
await loadIcons(icons, config);
}
Expand Down

0 comments on commit f160c4d

Please sign in to comment.