Async Initialization


Async initialization is particularly useful when the SDK script is loaded with the "defer" or "async" attributes, ensuring non-blocking behavior. The window.EditorSDKReady hook is provided to allow for initialization once the SDK is fully loaded.

Loading the SDK

<script async src="https://sdk.placid.app/editor-sdk@latest/sdk.js"></script>

In the snippet above, the async attribute on the script tag ensures that the SDK loads asynchronously, allowing the browser to continue rendering the page. This significantly improves the page load time.

Using the window.EditorSDKReady Hook

Upon loading, the SDK will invoke the window.EditorSDKReady function if it exists. This hook ensures that all necessary resources are available as soon as the callback executes, allowing for immediate interaction with the SDK.

window.EditorSDKReady = function() {
  // Your initialization code here
};

{info} Note: In Single Page Application (SPA) environments, it's possible to check if the SDK is already loaded on subsequent page loads by verifying the existence of window.EditorSDK.