Question: I would like to get the code below to wait for another script to be loaded before executing. How can I get this to wait for sp.js to load before executing?

```
$.getScript("/sites/MySite/SiteAssets/jquery.LISP.Quicklaunch.js", function(){});

jQuery(document).ready(function() {
jQuery('#s4-leftpanel').quicklaunchHide({
    collapseImage: '/_layouts/images/mewa_leftPage.gif',
    expandImage: '/_layouts/images/mewa_rightPage.gif',
    prependLocation: '.s4-tn',
    mainDiv: '.s4-ca',                            
    leftMargin: 0,    
    hideOnDefault: true,   
    allowCookie: true,
    cookieName: 'quicklaunchStatus'            
});

function setHeight() {
    windowHeight = $(window).innerHeight();
    $('#s4-mainarea').css('min-height', windowHeight-203);
};
setHeight();

$(window).resize(function() {
    setHeight();
});

jQuery('#s4-workspace').css('cssText', 'height: 262px !important');
});

```

Answer: 
Answer from comment. Please check the **[jQuery documentation](https://api.jquery.com/jquery.getscript/)**.

You just need to use a callback. If you want to execute your code after that `.getScript()`, put it inside the second parameter, which is currently a callback function:

```
$.getScript('path/to/script.js', function(){ 
    /* your code goes here */
});

```
Deferring execution of code is most simply done using a callback. For instance, if you have a function called `defer()` which you only want to execute after a function `dofirst()` has executed, you'd do this:

```
function dofirst(arguments, callback){
    //Do something here first, then call the callback
    callback();
};

function defer(arguments){
    //This is the code which you want to defer until the dofirst code has executed
    return;
}

//Invoke the function here
dofirst(arguments, defer);

```

hope this helps!