wf.ready()

This method ensures the Browser API is loaded on the page. It accepts a callback function that executes once the Browser API loads. Place any code you want to run after the Browser API is ready inside this callback function.

To make sure your code runs, always wrap your Browser API logic in wf.ready(). This ensures that the Browser API is loaded before your code runs.

Syntax

1wf.ready(callback: () => void): void

Parameters

  • callback: () => void - A function that executes once the Browser API is ready to use. Place any code using the Browser API methods inside of this callback function.

Example

1wf.ready( () => {
2 // Your code here
3 console.log("The Browser API is ready to use!");
4 const consentStatus = wf.getUserTrackingChoice();
5 console.log(consentStatus);
6});