简体   繁体   中英

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?

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, ie script.js

 var $script = require("scriptjs"); $script("//ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js", function() { // ... }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM