# 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](https://developer.nexx360.io/direct-integration-n360ortb/api-reference) - Learn about all available methods
* [Standalone Integration](https://developer.nexx360.io/direct-integration-n360ortb/standalone-integration) - Render ads without an ad server
* [GAM Integration](https://developer.nexx360.io/direct-integration-n360ortb/gam-integration) - Integrate with Google Ad Manager
