lib/HtmlParser.js
function _promiseAppendJQuery(obj) {
    const document = obj.document || obj;
    // append to body
    return Promise.resolve()
        .then(() => {
            if (JQUERY_SCRIPT) return JQUERY_SCRIPT;
            return fs.readFile(JQUERY_PATH, 'utf8');
        })
        .then(src => {
            JQUERY_SCRIPT = src;
            const el = document.createElement('script');
            el.type = 'text/javascript';
            el.innerHTML = src;
            el.className = 'jsdom-jquery';
            document.body.appendChild(el);
            return obj;
        });
}
function _promiseAppendJQuery(obj) {
    const document = obj.document || obj;
    // append to body
    return Promise.resolve()
        .then(() => {
            if (JQUERY_SCRIPT) return JQUERY_SCRIPT;
            return fs.readFile(JQUERY_PATH, 'utf8');
        })
        .then(src => {
            JQUERY_SCRIPT = src;
            const el = document.createElement('script');
            el.type = 'text/javascript';
            el.innerHTML = src;
            el.className = 'jsdom-jquery';
            document.body.appendChild(el);
            return obj;
        });
}
function _promiseAppendJQuery ( obj ) { const document = obj . document || obj ; // append to body return Promise . resolve ( ) . then ( ( ) => { if ( JQUERY_SCRIPT ) return JQUERY_SCRIPT ; return fs . readFile ( JQUERY_PATH , 'utf8' ) ; } ) . then ( src => { JQUERY_SCRIPT = src ; const el = document . createElement ( 'script' ) ; el . type = 'text/javascript' ; el . innerHTML = src ; el . className = 'jsdom-jquery' ; document . body . appendChild ( el ) ; return obj ; } ) ; }
Instead of appending a script tag with src attribute  (e.g. <script src="/script.js">); this reads the script file and inserts the code within a script tag. This is bec. we cannot know when a dynamically inserted script loads. see https://github.com/tmpvar/jsdom/issues/640#issuecomment-22216965
Instead of appending a script tag with src attribute ( e . g . <script src = / script . js > ) ; this reads the script file and inserts the code within a script tag . This is bec . we cannot know when a dynamically inserted script loads . see https : // github . com / tmpvar / jsdom / issues / 640#issuecomment - 22216965