diff --git a/src/runtime/third-party-scripts/nitro.plugin.ts b/src/runtime/third-party-scripts/nitro.plugin.ts index 82704d5..40d6760 100644 --- a/src/runtime/third-party-scripts/nitro.plugin.ts +++ b/src/runtime/third-party-scripts/nitro.plugin.ts @@ -39,9 +39,9 @@ function __hints_TPC_saveTime(script, startTime) { for (const script of document.scripts) { if (script.src && !script.src.startsWith(window.location.origin)) { script.__hints_TPC_start_time = window.__hints_TPC_start_time || Date.now(); - script.onload = function(_) { + script.addEventListener('load', () => { __hints_TPC_saveTime(script, script.__hints_TPC_start_time); - } + }) __hints_TPC_saveTime(script, script.__hints_TPC_start_time); } } diff --git a/src/runtime/third-party-scripts/plugin.client.ts b/src/runtime/third-party-scripts/plugin.client.ts index 2fc3d0e..cd89ec3 100644 --- a/src/runtime/third-party-scripts/plugin.client.ts +++ b/src/runtime/third-party-scripts/plugin.client.ts @@ -88,10 +88,10 @@ export default defineNuxtPlugin({ nuxtApp.callHook('hints:scripts:added', script) .then(() => { if (!script.loaded) { - script.onload = () => { + script.addEventListener('load', () => { window.__hints_TPC_saveTime(script, script.__hints_TPC_start_time) nuxtApp.callHook('hints:scripts:loaded', script) - } + }) } else { window.__hints_TPC_saveTime(script, script.__hints_TPC_start_time)