parent
5043c92d56
commit
79b68fdb2c
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@fwdekker/template",
|
"name": "@fwdekker/template",
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"description": "The base template for pages on fwdekker.com.",
|
"description": "The base template for pages on fwdekker.com.",
|
||||||
"author": "Felix W. Dekker (https://fwdekker.com)",
|
"author": "Felix W. Dekker (https://fwdekker.com)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -27,11 +27,17 @@ export const $ = q => document.querySelector(q);
|
||||||
/**
|
/**
|
||||||
* Runs the given function once the page is loaded.
|
* Runs the given function once the page is loaded.
|
||||||
*
|
*
|
||||||
* This function can be used multiple times. It does not overwrite existing callbacks for the page load event.
|
* This function can be used multiple times. It does not overwrite existing callbacks for the page load event. If the
|
||||||
|
* page has already loaded when this function is invoked, `fun` is invoked immediately inside this function.
|
||||||
*
|
*
|
||||||
* @param fun {function(...*): *} the function to run
|
* @param fun {function(...*): *} the function to run
|
||||||
*/
|
*/
|
||||||
export const doAfterLoad = function (fun) {
|
export const doAfterLoad = function (fun) {
|
||||||
|
if (document.readyState === "complete") {
|
||||||
|
fun();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const oldOnLoad = window.onload || (() => {
|
const oldOnLoad = window.onload || (() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue