动态加载javascript

使用以下函数

var dynamicLoading = {
    meta : function(){
        document.write('<meta charset="utf-8">');
        document.write('<meta http-equiv="X-UA-Compatible" content="IE=edge">');
        document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, shrink-to-fit=no">');
    },
    css: function(path){
        if(!path || path.length === 0){
            throw new Error('argument "path" is required!');
        }
        document.write('<link rel="stylesheet" type="text/css" href="' + path + '">');
    },
    js: function(path, charset){
        if(!path || path.length === 0){
            throw new Error('argument "path" is required!');
        }
        document.write('<script type="text/javascript" src="' + path + '"></script>');
    }
};
// 另外一个独立的动态加载js的函数
function loadJs(jsurl, head, callback) {
	var script = document.createElement(script);
	script.setAttribute("type", "text/javascript");

	if(callback) {
		if(script.readyState) { //IE
			script.onreadystatechange = function() {
				if(script.readyState == "loaded" ||
					script.readyState == "complete") {
					script.onreadystatechange = null;
					callback();
				}
			};
		} else { //Others
			script.onload = function() {
				callback();
			};
		}
	}
	script.setAttribute("src", jsurl);

	if(head)
		document.getElementsByTagName(head)[0].appendChild(script);
	else {
		document.body.appendChild(script);
	}
}