I’m trying not to be a lazy dev. Thus I want to only include my js files where they are needed.
As the js is needed everywhere where my shortcode is used I tried to do what was answered here.
//do the most awesomest of stuff
//..ok mostly changes textvalues dynamically
But that did not work. As “do_cool_stuff is not defined”.
Tried to do
return ‘<img src=”‘.admin_url().’/images/loading.gif” onload=”do_cool_stuff()”/>’;
Which works nicely from time to time. Implying its a race condition.
also does not work, as the headers are already send.
so… There ought to be a better way to do this.
Read more here:: How do I get rid of my inclusion race-condition on wp_enqueue_script