Ricky Han Ricky Han - 1 year ago 271
jQuery Question

How to include jQuery CDN in Webpack?

Since a CDN version of jQuery is very likely to be cached. Is there a way to include the CDN version in webpack as opposed to the local npm version.

What is the best way to include jQuery in Webpack if it's not loaded on the page?

Answer Source

This seems to have been discussed before, see https://github.com/webpack/webpack/issues/150. The response was:

webpack is a module bundler not a javascript loader. It package files from local disk and don't load files from the web (except its own chunks).

Use a javascript loader, i. e. script.js

var $script = require("scriptjs");
$script("//ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js", function() {
    // ... 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download