How to include jQuery CDN in Webpack?

吃可爱长大的小学妹 提交于 2019-12-08 19:34:19

问题


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?


回答1:


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() {
    // ... 
});


来源:https://stackoverflow.com/questions/39781951/how-to-include-jquery-cdn-in-webpack

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!