only load custom.js if present
This commit is contained in:
parent
cab2da5e62
commit
1983d025a4
3 changed files with 27 additions and 8 deletions
|
|
@ -9,6 +9,7 @@ import settings from './modules/settings.mjs';
|
|||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
init();
|
||||
getCustomCode();
|
||||
});
|
||||
|
||||
const categories = [
|
||||
|
|
@ -413,3 +414,15 @@ const fullScreenResizeCheck = () => {
|
|||
// store state of fullscreen element for next change detection
|
||||
fullScreenResizeCheck.wasFull = !!document.fullscreenElement;
|
||||
};
|
||||
|
||||
const getCustomCode = async () => {
|
||||
// fetch the custom file and see if it returns a 200 status
|
||||
const response = await fetch('scripts/custom.js', { method: 'HEAD' });
|
||||
if (response.ok) {
|
||||
// add the script element to the page
|
||||
const customElem = document.createElement('script');
|
||||
customElem.src = 'scripts/custom.js';
|
||||
customElem.type = 'text/javascript';
|
||||
document.body.append(customElem);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue