Async JavaScript load
This commit is contained in:
parent
c7f482c525
commit
e63be2c43a
@ -54,7 +54,7 @@ component Layout(app *aero.Application, ctx *aero.Context, user *arn.User, openG
|
||||
ExtensionNavigation(user)
|
||||
if user != nil
|
||||
#user(data-id=user.ID, data-pro=user.IsPro(), data-theme=user.Settings().Theme)
|
||||
script(src="/scripts")
|
||||
script(src="/scripts", async="async")
|
||||
script(type="application/ld+json")!= organization
|
||||
|
||||
component Content(content string)
|
||||
|
@ -3,7 +3,12 @@ import AnimeNotifier from "../AnimeNotifier"
|
||||
// Chrome extension installation
|
||||
export function installExtension(arn: AnimeNotifier, button: HTMLElement) {
|
||||
let browser: any = window["chrome"]
|
||||
browser.webstore.install()
|
||||
|
||||
if(browser && browser.webstore) {
|
||||
browser.webstore.install()
|
||||
} else {
|
||||
window.open("https://chrome.google.com/webstore/detail/anime-notifier/hajchfikckiofgilinkpifobdbiajfch", "_blank")
|
||||
}
|
||||
}
|
||||
|
||||
// Desktop app installation
|
||||
|
@ -83,9 +83,13 @@ export default class AnimeNotifier {
|
||||
// Event listeners
|
||||
document.addEventListener("readystatechange", this.onReadyStateChange.bind(this))
|
||||
document.addEventListener("DOMContentLoaded", this.onContentLoaded.bind(this))
|
||||
document.addEventListener("keydown", this.onKeyDown.bind(this), false)
|
||||
window.addEventListener("popstate", this.onPopState.bind(this))
|
||||
window.addEventListener("error", this.onError.bind(this))
|
||||
|
||||
// If we finished loading the DOM (either "interactive" or "complete" state),
|
||||
// immediately trigger the event listener functions.
|
||||
if(document.readyState !== "loading") {
|
||||
this.app.emit("DOMContentLoaded")
|
||||
this.run()
|
||||
}
|
||||
|
||||
// Idle
|
||||
requestIdleCallback(this.onIdle.bind(this))
|
||||
@ -176,6 +180,11 @@ export default class AnimeNotifier {
|
||||
}
|
||||
|
||||
async onIdle() {
|
||||
// Register event listeners
|
||||
document.addEventListener("keydown", this.onKeyDown.bind(this), false)
|
||||
window.addEventListener("popstate", this.onPopState.bind(this))
|
||||
window.addEventListener("error", this.onError.bind(this))
|
||||
|
||||
// Service worker
|
||||
this.serviceWorkerManager = new ServiceWorkerManager(this, "/service-worker")
|
||||
this.serviceWorkerManager.register()
|
||||
|
@ -26,12 +26,14 @@ export default class Application {
|
||||
}
|
||||
|
||||
init() {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let links = document.getElementsByTagName("a")
|
||||
document.addEventListener("DOMContentLoaded", this.onContentLoaded.bind(this))
|
||||
}
|
||||
|
||||
this.markActiveLinks(links)
|
||||
this.ajaxify(links)
|
||||
})
|
||||
onContentLoaded() {
|
||||
let links = document.getElementsByTagName("a")
|
||||
|
||||
this.markActiveLinks(links)
|
||||
this.ajaxify(links)
|
||||
}
|
||||
|
||||
get(url: string): Promise<string> {
|
||||
|
Loading…
Reference in New Issue
Block a user