简体   繁体   English

如何在Webpack中包括jQuery CDN?

[英]How to include jQuery CDN in Webpack?

Since a CDN version of jQuery is very likely to be cached. 由于CDN版本的jQuery很可能会被缓存。 Is there a way to include the CDN version in webpack as opposed to the local npm version. 有没有一种方法可以在Webpack中包含CDN版本,而不是本地npm版本。

What is the best way to include jQuery in Webpack if it's not loaded on the page? 如果未在页面上加载jQuery,则在Webpack中包括jQuery的最佳方法是什么?

This seems to have been discussed before, see https://github.com/webpack/webpack/issues/150 . 这似乎之前已经讨论过,请参见https://github.com/webpack/webpack/issues/150 The response was: 响应是:

webpack is a module bundler not a javascript loader. webpack是一个模块捆绑器,而不是JavaScript加载器。 It package files from local disk and don't load files from the web (except its own chunks). 它从本地磁盘打包文件,并且不从Web加载文件(其自身的块除外)。

Use a javascript loader, ie script.js 使用JavaScript加载程序,即script.js

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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