Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 721
Ricky Han Avatar asked Sep 30 '16 00:09

Ricky Han


1 Answers

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() {
    // ... 
});
like image 138
Felix Kling Avatar answered Oct 31 '22 10:10

Felix Kling