Skip to content

Commit b1943e0

Browse files
Merge pull request #7036 from segmentio/prigiattiperrut-patch-5
Clarify window.analytics.initialized behavior in documentation
2 parents 257fc81 + 079e31f commit b1943e0

File tree

1 file changed

+3
-1
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+3
-1
lines changed

src/connections/sources/catalog/libraries/website/javascript/index.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ analytics.identify("hello world")
362362

363363
The `ready` method lets you pass in a method that gets called after Analytics.js finishes initializing and after all enabled device-mode destinations load. It's like [jQuery's `ready` method](https://api.jquery.com/ready/){:target="_blank"}, except for Destinations. Because it doesn't fire until all enabled device-mode destinations are loaded, it can't be used to change configuration options for downstream SDKs. That can only be done if the SDK is loaded natively.
364364

365-
The `ready` method isn't invoked if any Destination throws an error (for example, for an expired API key, incorrect settings configuration, or when a Destination is blocked by the browser) during initialization. If you're looking to detect when Analytics.js has loaded, instead of using the `ready` method, you can listen for the `initialize` event to be emitted (`window.analytics.initialized`). This event returns `true` even when a destination is blocked.
365+
The `ready` method isn't invoked if any Destination throws an error (for example, for an expired API key, incorrect settings configuration, or when a Destination is blocked by the browser) during initialization. If you want to check when Analytics.js has loaded, you can look at the value of `window.analytics.initialized`. When it’s true, the library has successfully initialized, even if some destinations are blocked.
366+
367+
**Note**: `window.analytics.initialized` is a simple boolean, not an event or a pub/sub system. This means you can't subscribe to changes in its value. If you need to detect when it changes from `false` to `true`, you must set up a polling mechanism to monitor the value.
366368

367369
The code in the `ready` function only executes after `ready` is emitted.
368370

0 commit comments

Comments
 (0)