• Hi guys,

    I’m Bar?? from Optimocha, and I’m a speed optimization expert. (We actually spoke with Michael Bova last year about some partnership opportunity, but he never got around to make a decision I guess.) I found a way to speed up your ads’ loading process by making a small change in the JavaScript code you’re outputting via adthrive-ads/components/ads/partials/ads.php, which helped one of our clients big time. Here’s your code:

    window.adthrive = window.adthrive || {};
    window.adthrive.cmd = window.adthrive.cmd || [];
    window.adthrive.host = 'ads.adthrive.com';
    window.adthrive.plugin = 'adthrive-ads-1.0.36';
    window.adthrive.threshold = Math.floor(Math.random() * 100 + 1);
    
    (function() {
    	var script = document.createElement('script');
    	script.async = true;
    	script.type = 'text/javascript';
    	script.src = 'https://ads.adthrive.com/sites/5458d0c6f2e448057ed3b4d2/ads.min.js?threshold=' + window.adthrive.threshold;
    	var node = document.getElementsByTagName('script')[0];
    	node.parentNode.insertBefore(script, node);
    })();

    And here’s my tweaked version:

    window.adthrive = window.adthrive || {};
    window.adthrive.cmd = window.adthrive.cmd || [];
    window.adthrive.host = 'ads.adthrive.com';
    window.adthrive.plugin = 'adthrive-ads-1.0.36';
    window.adthrive.threshold = Math.floor(Math.random() * 100 + 1);
    
    function adthrive_deferred() {
    	var script = document.createElement('script');
    	script.async = true;
    	script.type = 'text/javascript';
    	script.src = 'https://ads.adthrive.com/sites/5458d0c6f2e448057ed3b4d2/ads.min.js?threshold=' + window.adthrive.threshold;
    	var node = document.getElementsByTagName('script')[0];
    	node.parentNode.insertBefore(script, node);
    }
    
    if (window.addEventListener)
    	window.addEventListener('load', adthrive_deferred, false);
    else if (window.attachEvent) window.attachEvent('onload', adthrive_deferred);
    else window.onload = adthrive_deferred;

    As you can probably understand, I’m making the ads load after the browser’s onload event so all those ad-related assets load just a bit later than the rest of the page is loaded & mostly parsed.

    I figured you might want to have this code for all your clients, so I wanted to post it. Cheers! ??

  • The topic ‘A suggestion to make your ads load better/faster’ is closed to new replies.