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

TDW-1646 Admiral #123

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 0 additions & 24 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,27 +755,3 @@ const hasWeFevo = document.querySelector('a.we-fevo-btn');
if (hasWeFevo) {
injectWeFevoScript();
}

/**
* Loads Admiral script
*/
function loadAdmiral() {
const fetchScript = async () => {
try {
const response = await fetch(
'https://orchestrator-config-uat.pgatour.com/revops/admirial',
);
const content = await response.text();
const script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = content;
script.id = 'admiral';
document.head.appendChild(script);
} catch (error) {
throw new Error('Error loading Admiral script: ', error);
}
};
fetchScript();
}

loadAdmiral();
20 changes: 20 additions & 0 deletions scripts/dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Loads Admiral script
*/
async function loadAdmiral() {
try {
const response = await fetch(
'https://orchestrator-config-uat.pgatour.com/revops/admirial',
);
const content = await response.text();
const script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = content;
script.id = 'admiral';
document.head.appendChild(script);
} catch (error) {
throw new Error('Error loading Admiral script: ', error);
}
}

loadAdmiral();
10 changes: 10 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,13 +1052,23 @@ async function loadEager(doc) {
}
}

/**
* Loads everything that required HTML to be in place.
*/
function loadDependencies() {
// eslint-disable-next-line import/no-cycle
import('./dependencies.js');
}

/**
* loads everything that doesn't need to be delayed.
*/
async function loadLazy(doc) {
const main = doc.querySelector('main');
await loadBlocks(main);

loadDependencies();

const { hash } = window.location;
const element = hash ? main.querySelector(hash) : false;
if (hash && element) element.scrollIntoView();
Expand Down
Loading