如何在Webpack中包含jQuery CDN? [英] How to include jQuery CDN in Webpack?

查看:100
本文介绍了如何在Webpack中包含jQuery CDN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为jQuery的CDN版本很可能被缓存。有没有办法在webpack中包含CDN版本而不是本地npm版本。

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.

如果页面上没有加载jQuery,最好的方法是什么?

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

推荐答案

这似乎已在之前讨论过,请参阅 https:// github。 COM /的WebPack /的WebPack /问题/ 150 。回复是:

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


webpack是一个模块捆绑器而不是javascript加载器。它从本地磁盘打包文件
并且不从Web加载文件(除了它自己的
块)。

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).

使用javascript加载器,一世。即 script.js

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


这篇关于如何在Webpack中包含jQuery CDN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆