---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.ru/support/adfox/en/ad-inventory/codes/change-code.md
  - https://yandex.ru/support/adfox/ru/ad-inventory/codes/change-code.md
  - href: en/ad-inventory/codes/change-code.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/support/adfox/en/llms.txt


# Switching to the new embed code

Since July 20, 2021, Adfox has used the universal ad loader code. Different loader codes were previously used to load different types of Yandex Advertising Network and Adfox units. With the new codes, the browser does not waste time accessing multiple loads, so ads are served faster. The new Adfox banner code is now asynchronous by default and contains a single yaContextCb loading queue, which optimizes loading for different types of ads on the page. 

The old embed codes are compatible with the new ones, so you can change the banner codes on the pages of your site gradually. We recommend that you first make changes to one of the codes on the page and make sure that it works properly, and then move on to the next one.

## Replacing the old ad code with the new one {#new-code}

You can get the new ad code in the Adfox interface:

- At the site level: Open the **Inventory** tab and click ![](../../_images/code.svg)**Ad tag** next to the site name.
- At the platform level: Go to **Inventory** → **Sections** → **Placements** and click ![](../../_images/code.svg)**Ad tag** next to the name of the site.
- At the banner level: On the **Campaigns** tab, select a campaign, go to **Banners** → **Placement** and click ![](../../_images/code.svg)**Ad tag** next to the desired placement.

To replace the ad code manually:

1. Add the ad loader code to the `<head>` of each page where the ad is displayed:

    ```html
    
    
    ```
    
    {% note info %}
    
    The ad loader code is the same for all types of Yandex ads. If the page already contains [separate codes for Yandex Advertising Network units](https://yandex.com/support2/partner/en/web/units/tag-features) or a [recommendation widget](https://yandex.com/support2/partner/en/web/recommendation-widget/create), you don't need to duplicate the ad loader code.
    
    {% endnote %}
    
1. Remove the scripts with the old code loaders from the banner code:
    - ``
    - ``
    - ``
    
1. Add new lines to the banner code:

    ```javascript
    window.yaContextCb.push(()=>{
    ...
    })
    ```
    
    #|
    || **Old code** | **New code** ||
    || 

    ```html
    <div id="adfox_162624621735476317"></div>
    

    ``` 

    | 

    ```html
    <div id="adfox_162624621735476317"></div>
    
    ```

    ||
    |#
    

**How the new code works**

The ad rendering function is no longer called immediately, but is added to a single call queue. When the browser downloads and runs the loader code, it parses the queue and calls the ad block ad codes. If the loader is already in the browser cache when loading the page, the embed codes are run faster.

**Example of the new ad code**

```html
<!--In the site <head>, add the loader code once-->



<!--Adfox START-->
<!--login-->
<!--Platform: example.pro / * / *-->
<!--Banner type: 100%х250 -->
<!--Position: <top>-->
<div id="adfox_16244342575025707"></div>

```


{% note info %}

If you use the Header Bidding code on your site pages, you should change it, too. [Learn more about replacing the Header Bidding code](https://yandex.com/support/adfox-sites/monetization/hb-change-code.html)

{% endnote %}


## Replacing the obsolete asynchronous embed code {#from-old}

If your site uses obsolete asynchronous ad code, replace it with the new one.

Code correspondence:

**Tag type** | **Obsolete code** | **New code**
----- | ----- | -----
Asynchronous code | `adfoxAsyncParams` | `Ya.adfoxCode.create`
Adaptive code | `adfoxAsyncParamsAdaptive` | `Ya.adfoxCode.createAdaptive`


Examples of replacing obsolete asynchronous code with the new one:

#|
|| **Obsolete code** | **New code** ||
||

  ```html
  <div id="adfox-id"></div>
  
  ```

|

  ```html
  <div id="adfox-id"></div>
  
  ```

||
|#


<!-- source: en/_includes/feedback.md -->
## Contact support


<a href="en/form"> <!--ссылка, куда ведет кнопка. Если внутренняя ссылка, пишем без .md и .html --> 
  <span class="button">Send an email</span> <!--текст на кнопке--> 
</a>



<!-- source: en/_includes/styles/button.md -->

<!-- endsource: en/_includes/styles/button.md -->
<!-- endsource: en/_includes/feedback.md -->
