Javascript problem with WP Super Cache

Recently had a case where Tweet Blender didnt work correctly alongside WP Super Cache.

Tweet Blender showed the Tweets that was cached along with the page so in effect 3 weeks later you still have tweets from 3 weeks back showing.

The workaround was quite easy, All you have to do is refresh the tweet blender box as soon as the page is done loading.

So in your functions.php you add the following code:


add_action('wp_head','blenderfix');

function blenderfix() {
 ?>
 <script type="text/javascript">
 jQuery(window).bind("load",function(){
 jQuery('body').prepend('<div style="display:none">Check</div>');
 TB_blend('tweetblender-11');
 });
</script>
<?php }

Explained:

Add the action for including the javascript in your page head. Then add a jquery function to run TB_Blend as soon as the window is done loading.

After you saved that. Browse to the supercache folder delete cached file of the home page so the new script will be loaded.

Janes Oosthuizen

Author Janes Oosthuizen

Programmer and Tech Junky from Bloemfontein, South-Africa. I have been programming for 8 years in various languages including ( CSS, HTML, jQuery, PHP, MySQL, Wordpress and many other ).

More posts by Janes Oosthuizen

Leave a Reply