Neanderthal
Behold the miracle that is neanderthal.js the only javascript you will ever need on any html document.
function atr(a){
if(typeof(window[a]) === 'function'){
window[a]();
}else{
s = document.createElement("script");
s.src = "a.js?action=" + a;
s.onload = s.onreadystatechange = function() {
if (!this.readyState || this.readyState === 'complete') {
this.readyState = 'xxx';window[a]();
}
};
document.head.appendChild(s);
}
}
Thats it I hear you wonder!
Indeed, this is all the javascript you need to load to create most of the functionality one would normally look for.
What about the arguments I hear you.
For an interactive application it would be apropriate if your url reflects the state of the application.
Wanting to pass arguments to your function is just annother way of saying you are to lazy to do this properly.
See how I got you there?
lets just try this stuff?
Say we have one of those links we talked about just now.
<a href="?action=unicorn" onclick="atr('unicorn');return false;">unicorn</a>
Which would produce something like this:
unicorn
If you click on that (go ahead try it) the unicorn functionality will be implemented on the fly.
These things are accomplished by attaching a.js to the dom forest. Inside a.js there is the unicorn functionality we desired.
function unicorn() { alert('unicorn'); }
Now you can go clutter up your website with fancy scripts the way we all know you wanted to.
Good luck!