title: Inject jQuery into Puppeteer page
body: <p>I'm trying to inject jQuery into my Puppeteer page because <code>document.querySelector</code> doesn't cut it for me:</p>
  
  <pre><code>async function inject_jquery(page){
    await page.evaluate(() =&gt; {
      var jq = document.createElement("script")
      jq.src = "https://code.jquery.com/jquery-3.2.1.min.js"
      document.querySelector("head").appendChild(jq)
    })
    const watchDog = page.waitForFunction('window.jQuery !== undefined');
    await watchDog;
  }
  </code></pre>
  
  <p>The result is it mostly times out. Does anyone have a solution?</p>