> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scripting: Loading and Initialization

> Use twttr.widgets.load to scan the DOM and initialize new X for Websites buttons or widgets added dynamically through lazy loading or pushState navigation.

## 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")
);
```
