If you’d like to load the iubenda button asynchronously after loading other site content (rather than initializing on page load as is default), simply follow the steps outlined below.
Place the following function in the page BODY
. As this will be used instead of the standard embed code, please be sure to replace Xxxxxx
(seen in the example below) with your own privacy policy id.
function startIubendaBadge() { /** After dynamic content... **/ var loadIubendaBadge = function() { var s = document.createElement("script"), tag = document.getElementsByTagName("script")[0]; s.src = "https://cdn.iubenda.com/iubenda.js"; tag.parentNode.insertBefore(s, tag); }; var aLink = $('<a href="https://www.iubenda.com/privacy-policy/Xxxxxx" class="iubenda-black iubenda-embed" title="Privacy Policy ">Privacy Policy</a>'); $('#element-id-containing-badge').append(aLink); loadIubendaBadge(); };
You can then implement this by adding the iubenda callback to the function that loads your dynamic content.
For example,
function initializeWebSiteContent() {
// create list
// populate list
// apply style to list
startIubendaBadge();
}