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 */
});

```
I ended up doing it this way:

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

jQuery(document).ready(function() {
    ExecuteOrDelayUntilScriptLoaded(delayedExecute, "sp.js");
});

function delayedExecute(){
    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();
        listHeight = windowHeight - 180;
        jQuery('#s4-workspace').css('cssText', 'height: ' + listHeight + 'px !important');
    };
    setHeight();

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

```