thanhpk
6/23/2016 - 6:30 AM

Add JQuery programatically to a page use Google Console

Add JQuery programatically to a page use Google Console

function addJquery(cb) {
	if (typeof(jQuery) !== 'undefined') return;
	var url = 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js';
	var scr = document.createElement('script'); scr.setAttribute('type', 'text/javascript'); scr.setAttribute('src', url);
	var head = document.getElementsByTagName('head')[0]; head.insertBefore(scr, head.firstChild);  
}

addJquery();