> ## 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.

# Set up X for Websites

> Set up X for Websites by adding the widgets.js asynchronous loader snippet to your site template for faster widget rendering and reliable embed support.

The easiest way to create a X for Websites widget — a Post button, Follow button, embedded Post or timeline — is to use our configuration tools at [publish.x.com](https://publish.x.com) then copy and paste the generated HTML code into the template or widget area for your site.

* [Generate markup for a Post or Follow button](https://publish.x.com)
* [Generate markup for an embedded Post or timeline](https://publish.x.com)

## For best performance and reliability, include the widgets.js script in your template

Include the X for Websites JavaScript once in your page template for optimal web page performance and to enable tracking of [X widget JavaScript events](/x-for-websites/javascript-api/guides/javascript-api).

If your site is using multiple widgets you can set up X widgets in your pages once, which will make your site faster, and widgets such as embedded Posts will be more reliable for authors when using content management systems.

```html theme={null}
<script>window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return t;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.x.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);

  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };

  return t;
}(document, "script", "twitter-wjs"));</script>
```

The above snippet optimizes loading by:

1. Assign an HTML element ID of `twitter-wjs` to easily identify if the JavaScript file already exists on the page. Exit early if the ID already exists.
2. Asynchronously load the Twitter for Websites JavaScript.
3. Initialize an asynchronous function queue to hold dependent functions until the script is available.

Include this snippet before any other JavaScript on your page which may depend on the `twttr.ready` asynchronous function queue.

## Ignore script tags from embeds

If you include the X JavaScript loader on every page you do not need to include the `<script>` element generated by a button configurator, embedded Post, or embedded Timeline tool. You can delete the extra `<script>` HTML from generated markup.

If you use the [oEmbed API](/x-for-websites/oembed-api) to include Posts in your content, you can generate embed codes that don’t include the `<script>` element by passing `omit_script=true` in the query string.
