In this case that doesn't work. I need to add this bootstrap plugin on demand from an infusion using the add_to_footer() function. Adding it to the theme would not be appropriate.
I managed to work around this by altering /themes/templates/layout.php and moving the bootstrap lines above the add_to_footer() output, but now I've changed a core PHPFusion file, which will be overwritten during an update. This is bad practice.
Optimally the add_to_footer() function should be adding extra JS scripts after bootstrap.min.js by default, or we should have an option to force it when necessary.
Most bootstrap javascript widgets and plugins require the core bootstrap.js to be loaded first anyway.
Haven't tested this at all, and I currently do not have R3 setup. If someone can test this and confirm that would be great. But here's an idea, maybe call your script via jQuery. JavaScript is client side, so this should be called after the rest has been parsed. Worth a shot.
That might work, so long as the plugin isn't wrapped in something that would break the import. It's kind of an ugly solution but I'll try it. Not sure that this would help all scenarios.
In the end the best solution is for bootstrap to come out first in the javascript order.
I'll test this and report back though as it may help others in the meantim.