Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
How do you import a local jQuery into webview for VS Code extensions?

how does one import jquery into webview? I attempted to modify:

https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/

to utilize the jquery library by adding it to the same location as main.js and then adding something like this:

const jqueryPathOnDisk = vscode.Uri.joinPath(this._extensionUri, 'media', 'jquery-3.6.0.min.js');
const jqueryUri = (jqueryPathOnDisk).with({ 'scheme': 'vscode-resource' });

followed by

<script nonce="${nonce}" src="${jqueryUri}"></script>

Around here in the code:

https://github.com/microsoft/vscode-extension-samples/blob/116b0aa1ade25bfd3c6f3df0847200089b82b72f/webview-sample/src/extension.ts#L171

But unfortunately this doesn’t seem to work.

I've also attempted to delete the following line:

                <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src ${webview.cspSource}; img-src ${webview.cspSource} https:; script-src 'nonce-${nonce}';">

from this file: https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts

And then importing a cdn but that also does not work. No matter what window.jQuery returns undefined.

Any insight would. be appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!