$( '#buttontest' ).on( 'click', function() { $.getScript( 'url to your js file', function( data, textStatus, jqxhr ) { // do some stuff after script is loaded } ); } );