• Firstly thanks for the great plugin. This is one of the few plugins that works successfully with caching frameworks without trashing performance 🙂

    In my case I wanted to use the js based ad rendering as I am using the supercache plugin. However I also want to include jQuery in the footer not the head. This will not work because this plugin renders inline javascript i.e.

    <div id="abc"></div>
    <script>
    $('#abc').load(url)
    </script>

    This means jquery must be rendered before this inline code. To work around this I modified the plugin so that instead of rendering the JS inline it renders the url as a data attribute of the div then I use some JS in the footer to grab the data attribute and load the content:

    <div id="abc" data-dfads-query="url"></div>
    ...
    <script src="jquery"></script>
    <script src="render.js"></script>

    render js:

    $('.dfads-javascript-load').each(function() {
        var elementId = $(this).attr('id');
        var query = $(this).data('dfads-query');
        $('#' + elementId).load(query);
    });

    If anyone is interested I’ve created a patch with the relevant modifications. To apply the patch go to the plugin directory and run
    patch -p1 < patch.diff.
    It should modify two files (dfads.php and inc/dfads.class.php) and create a new file (js/render.js)

    https://wordpress.org/plugins/ads-by-datafeedrcom/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    thanks for sharing , I was looking for something like this.
    Does this make make it possible to have the jquery work on both header and footer ads or just the footer ?

    Thread Starter thobson

    (@thobson)

    It should work for both although I haven’t tested it fully

    I’ve installed the patch but it doesn’t do anything, do I have to do something else except install the patch ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Patch to allow javascript loaded ads when jQuery is referenced in the footer’ is closed to new replies.