feat(client): prefetch next challenge (#55472)

Co-authored-by: ahmad abdolsaheb <ahmad.abdolsaheb@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Huyen Nguyen
2024-07-19 01:12:07 -07:00
committed by GitHub
parent fe4cd80c1e
commit 29607fb473
3 changed files with 32 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
declare global {
interface Window {
// This is a feature Gatsby adds to the `window` object.
// https://github.com/gatsbyjs/gatsby/blob/deb41cdfefbefe0c170b5dd7c10a19ba2b338f6e/packages/gatsby/cache-dir/production-app.js#L28
___loader: {
hovering: (path: string | null) => void;
};
}
}
export {};
+10
View File
@@ -0,0 +1,10 @@
/**
* The function is useful in cases where we want to preload a page
* but the link of the page isn't rendered on the screen.
* For more details, see https://github.com/freeCodeCamp/freeCodeCamp/pull/55472.
*/
export const preloadPage = (path: string | null) => {
if (!window.___loader || !path) return;
window.___loader.hovering(path);
};