Skip to content

Commit

Permalink
refactor: Decrease bundle size by 3%
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert committed Jan 27, 2025
1 parent 433510b commit 0d5e79c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/entrypoints/external-scripts-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { PostHog } from '../posthog-core'
import { addEventListener } from '../utils'
import { assignableWindow, document, PostHogExtensionKind } from '../utils/globals'
import { createLogger } from '../utils/logger'

Expand Down Expand Up @@ -42,7 +41,10 @@ const loadScript = (posthog: PostHog, url: string, callback: (error?: string | E
if (document?.body) {
addScript()
} else {
addEventListener(document, 'DOMContentLoaded', addScript)
// Inlining this because we don't care about `passive: true` here
// and this saves us ~3% of the bundle size
// eslint-disable-next-line posthog-js/no-add-event-listener
document?.addEventListener('DOMContentLoaded', addScript)
}
}

Expand Down

0 comments on commit 0d5e79c

Please sign in to comment.