# Installation

The n360ortb library uses an asynchronous loader pattern that ensures the library loads without blocking page rendering while allowing you to queue commands immediately.

## Async Loader Snippet

Add the following snippet to the `<head>` section of your page:

```javascript
!function(){if(!window.n360ortb){window.n360ortb={init:function(){e("init",arguments)},fetchBids:function(){e("fetchBids",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},que:[]};var n=document.createElement("script");n.async=!0,n.src="https://lib.nexx360.io/nexx360ortb/api.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t)}function e(n,t){window.n360ortb.que.push([n,t])}}();
```

### Formatted Version

Here's the same snippet formatted for readability:

```javascript
!function() {
  if (!window.n360ortb) {
    window.n360ortb = {
      init: function() { e("init", arguments) },
      fetchBids: function() { e("fetchBids", arguments) },
      setDisplayBids: function() {},
      targetingKeys: function() { return [] },
      que: []
    };

    var n = document.createElement("script");
    n.async = !0;
    n.src = "https://lib.nexx360.io/nexx360ortb/api.js";

    var t = document.getElementsByTagName("script")[0];
    t.parentNode.insertBefore(n, t);
  }

  function e(n, t) {
    window.n360ortb.que.push([n, t]);
  }
}();
```

## How It Works

The loader snippet creates a stub object on `window.n360ortb` that queues all API calls until the full library loads. This pattern allows you to:

1. **Call methods immediately** - No need to wait for script load events
2. **Non-blocking load** - The script loads asynchronously
3. **Guaranteed execution order** - Commands execute in the order they were called

## Script URL

The library is served from Nexx360's CDN:

```
https://lib.nexx360.io/nexx360ortb/api.js
```

{% hint style="info" %}
The library is automatically updated with bug fixes and improvements. No action is required on your part to receive updates.
{% endhint %}

## Command Queue Pattern

You can start calling n360ortb methods immediately after including the loader snippet:

```javascript
// These calls are queued and will execute once the library loads
n360ortb.init({
  currency: 'EUR'
});

n360ortb.fetchBids({
  slots: [
    { tagId: 'my-tag', divId: 'ad-div', sizes: [[300, 250]] }
  ]
}, function(bids) {
  console.log('Bids:', bids);
});
```

## Complete HTML Example

```html
<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>

  <!-- n360ortb loader snippet -->
  <script>
  !function(){if(!window.n360ortb){window.n360ortb={init:function(){e("init",arguments)},fetchBids:function(){e("fetchBids",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},que:[]};var n=document.createElement("script");n.async=!0,n.src="https://lib.nexx360.io/nexx360ortb/api.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t)}function e(n,t){window.n360ortb.que.push([n,t])}}();
  </script>

  <!-- Initialize n360ortb -->
  <script>
    n360ortb.init({
      currency: 'EUR'
    });
  </script>
</head>
<body>
  <!-- Your page content -->
</body>
</html>
```

## Next Steps

* [API Reference](/integration-methods/direct-integration-n360ortb/api-reference.md) - Learn about all available methods
* [Standalone Integration](/integration-methods/direct-integration-n360ortb/standalone-integration.md) - Render ads without an ad server
* [GAM Integration](/integration-methods/direct-integration-n360ortb/gam-integration.md) - Integrate with Google Ad Manager


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.nexx360.io/integration-methods/direct-integration-n360ortb/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
