Skip to content

Commit 1739680

Browse files
committed
fix(third-party): use eventlisteners for load event
1 parent 24c5d97 commit 1739680

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/runtime/third-party-scripts/nitro.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ function __hints_TPC_saveTime(script, startTime) {
3939
for (const script of document.scripts) {
4040
if (script.src && !script.src.startsWith(window.location.origin)) {
4141
script.__hints_TPC_start_time = window.__hints_TPC_start_time || Date.now();
42-
script.onload = function(_) {
42+
script.addEventListener('load', () => {
4343
__hints_TPC_saveTime(script, script.__hints_TPC_start_time);
44-
}
44+
})
4545
__hints_TPC_saveTime(script, script.__hints_TPC_start_time);
4646
}
4747
}

src/runtime/third-party-scripts/plugin.client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export default defineNuxtPlugin({
8888
nuxtApp.callHook('hints:scripts:added', script)
8989
.then(() => {
9090
if (!script.loaded) {
91-
script.onload = () => {
91+
script.addEventListener('load', () => {
9292
window.__hints_TPC_saveTime(script, script.__hints_TPC_start_time)
9393
nuxtApp.callHook('hints:scripts:loaded', script)
94-
}
94+
})
9595
}
9696
else {
9797
window.__hints_TPC_saveTime(script, script.__hints_TPC_start_time)

0 commit comments

Comments
 (0)