Dynamically loading Javascript files

The little snippet below lets you load JS files dynamically, making it easier to load jQuery or mootools for scripts like GreaseMonkey or within Firebug.

var jsfile = document.createElement("script");
jsfile.setAttribute("type", "text/javascript");
jsfile.setAttribute("src", "

Using Firebug, I used the following mootools code to hide some elements as a test to see if the script actually loaded.

$each($$('.saveType, .perType'), function(item) {
  item.setStyle('display', 'none');

Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog