(function($) { var boostrap_script = document.createElement('script'); boostrap_script.setAttribute('src','https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'); var bootstrap_enabled = (typeof $.fn.modal == 'function'); if(!bootstrap_enabled) { $(window).load(function(){ document.head.appendChild(boostrap_script); }); } })(jQuery);