Add JS and Style injection into AppShell
This commit is contained in:
12
src/public/head.ts
Normal file
12
src/public/head.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// Client-side script that runs in <head>
|
||||
// Example: TypeScript with DOM types
|
||||
(() => {
|
||||
const logPageInfo = (): void => {
|
||||
console.log('Page loaded in <head>');
|
||||
};
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
logPageInfo();
|
||||
}
|
||||
})();
|
||||
|
||||
16
src/public/onLoad.ts
Normal file
16
src/public/onLoad.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// Client-side script that runs on page load
|
||||
// Example: TypeScript with type annotations
|
||||
(() => {
|
||||
const setupPage = (): void => {
|
||||
const links: NodeListOf<HTMLAnchorElement> = document.querySelectorAll('a');
|
||||
console.log(`Found ${links.length} links on the page`);
|
||||
};
|
||||
|
||||
// Run setup when DOM is ready
|
||||
if (document.readyState !== 'loading') {
|
||||
setupPage();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', setupPage);
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user