From 1739680837039e3b6464a13c3461e0c396ed6ce8 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Mon, 8 Dec 2025 21:17:49 +0100 Subject: [PATCH] fix(third-party): use eventlisteners for load event --- src/runtime/third-party-scripts/nitro.plugin.ts | 4 ++-- src/runtime/third-party-scripts/plugin.client.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/third-party-scripts/nitro.plugin.ts b/src/runtime/third-party-scripts/nitro.plugin.ts index 82704d54..40d67607 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 2fc3d0ec..cd89ec35 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)