Load external JS file
Load JS external after page ready
by Marcel Kohls
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
<div>content on document</div>
<script type="text/javascript">
console.log('content on the document, before loading lib');
</script>
JavaScript
//incorporates and executes inmediatelly
$( document ).ready(function() {
$.getScript( "https://rawgit.com/Godoy/c8cba89030c44e163997ed675c7fc0cd/raw/d67b5788c35a039e554d58e4dd24e57b9e5d519c/my_function-sdk.js", function( data, textStatus, jqxhr ) {
console.log( data ); // Data returned
console.log( textStatus ); // Success
console.log( jqxhr.status ); // 200
console.log( "Load was performed." );
my_function('test content after page loaded');
});
});