> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-9523e74a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Scripting: Loading and Initialization

> Most X for Websites integrations will be well served by the recommended embed code found in the set-up documentation, but you may want to optimize how and.

## Initializing embedded content after a page has loaded

Most X for Websites integrations will be well served by the recommended embed code found in the [set-up documentation](/x-for-websites/javascript-api/guides/set-up-x-for-websites), but you may want to optimize how and when the Twitter for Websites JavaScript widgets scans the page DOM to discover new HTML elements eligible for enhancement into buttons or widgets.

If content is dynamically inserted into a page (such as lazy-loading content or using a `pushState` technique to navigate between articles) it’s necessary to parse new buttons and widgets using the `twttr.widgets.load()` function.

```javascript theme={null}
twttr.widgets.load()
```

Called without argument, `widgets-js` will search the entire `document.body` DOM tree for uninitialized widgets. For better performance, pass an `HTMLElement` object to restrict the search only to children of the element.

Example:

```javascript theme={null}
twttr.widgets.load(
  document.getElementById("container")
);
```
