Patch to allow javascript loaded ads when jQuery is referenced in the footer
-
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)
- The topic ‘Patch to allow javascript loaded ads when jQuery is referenced in the footer’ is closed to new replies.