Javascript: Dynamically load a new script

There are plenty of ways to do this but this is the simplest:

Go to the javascript console in your browser and type:

var script = document.createElement("script"); 
script.src = ""

You have now loaded Mustache.js into the browser. Let's use it:

Mustache.render("hi {{name}}!", { name: "dave" });

It will render hi dave! in the console.


Edit on github
comments powered by Disqus
Click me