Dynamic Content

This section is for websites whose content loads or changes dynamically.

Changing Pages

When switching between pageviews dynamically, it is important to call


ezstandalone.refresh() tells standalone that there is a new pageview and calls for new ad code for the defined placeholders.

If the new page contains a different set of placeholders from the previous page, ezstandalone.define() should be called with the new set of placeholders prior to calling refresh.

2    ezstandalone.cmd.push(function() {
3        // define new placeholders and call refresh
4        ezstandalone.define(104, 105, 106);
5        ezstandalone.refresh();
6    });

Calling define will overwrite the previous set of placeholders, so make sure to add any placeholders that persist from the previous set.

If placeholders 103 and 104 exist on page for example.com/page1 and the user dynamically changes to page example.com/page2 where placeholders 104 and 105 exist. Placeholder 105 must be included in the define call.

New Content

For additional placeholders within the same pageview, there is the ezstandalone.displayMore function.

If a user scrolls down the page, new content loads, and placeholders 104 and 105 are added, ezstandalone.displayMore should be used to display them.

2    ezstandalone.cmd.push(function() {
3        // call new placeholders
4        ezstandalone.displayMore(104, 105);
5    });

Changing content

If the content changes within the same pageview and a placeholder is no longer needed or visible, the placeholder needs to be properly cleaned up using ezstandalone.destroyPlaceholders. This allows the placeholder to be loaded again via ezstandalone.displayMore if necessary.

2    window.ezstandalone.cmd.push(function() {
3        // destroy placeholders
4        ezstandalone.destroyPlaceholders(104, 105);
5    });

Infinite Scroll

For sites which implement an infinite scroll, a combination of calling ezstandalone.destroyPlaceholders followed by ezstandalone.displayMore may be necessary to reuse placeholders if within the same pageview.

It is recommended to create a set of in-content placeholders specifically for infinite scroll.


The example below shows the flow of an infinite scroll would look like on a site with multiple articles.

Start off by calling the placeholder for the first article on page load.

2    window.ezstandalone = window.ezstandalone || {};
3    ezstandalone.cmd = ezstandalone.cmd || [];
4    ezstandalone.cmd.push(function() {
5        ezstandalone.define(102, 103, 104);
6        ezstandalone.enable();
7        ezstandalone.display();
8    });

User then scrolls to the next article, so the next set of ads are loaded.

2    window.ezstandalone.cmd.push(function() {
3        // call new placeholders
4        ezstandalone.displayMore(105, 106);
5    });

User then scrolls to the third article, and the placeholders from the first article need to be reused.

2    window.ezstandalone.cmd.push(function() {
3        // destroy initial placeholders
4        ezstandalone.destroyPlaceholders(102, 103, 104);
5        // call new placeholders
6        ezstandalone.displayMore(102, 103, 104);
7    });

Removing all placeholders

Remove all placeholders on the page by using the destroyAll function

2    window.ezstandalone.cmd.push(function() {
3        ezstandalone.destroyAll();
4    });