I’d like to be able to load Firebug lite conditionally (eg, based on the value of debug variable). I’ve tried this:
<script type="text/javascript">
var fileref;
if(condition) {
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", "https://getfirebug.com/firebug-lite.js")
}
</script>
at the top of my <head>, but to no avail. Anyone have any suggestions?
After creating an element, you need to insert it into the DOM. This can be done using
.appendChild().Add this to your
if: