diff --git a/docs/source/embedding.md b/docs/source/embedding.md index 7faa8a5b50..55ed74fe8c 100644 --- a/docs/source/embedding.md +++ b/docs/source/embedding.md @@ -123,9 +123,9 @@ html_template = """ @@ -179,7 +179,7 @@ In this example, we used a Python string for the template, and used the documents, you may want to use a templating engine like [Jinja2](http://jinja.pocoo.org/). -We also change the CDN from its default of unpkg to use jsdelivr by setting the +We also change the CDN from its default of jsdelivr to use unpkg by setting the `data-jupyter-widgets-cdn` attribute. What's more, we only load modules from the CDN by setting the @@ -263,14 +263,14 @@ documentation. An illustration of this is the http://jupyter.org/widgets gallery. The widget embedder attempts to fetch the model and view implementation of the -custom widget from the npm CDN https://unpkg.com by default. The URL that is requested +custom widget from the npm CDN https://cdn.jsdelivr.net/npm by default. The URL that is requested for, e.g. the `bqplot` module name, with the semver range `^2.0.0` is -`https://unpkg.com/bqplot@^2.0.0/dist/index.js` +`https://cdn.jsdelivr.net/npm/bqplot@^2.0.0/dist/index.js` which holds the webpack bundle for the bqplot library. -While the default CDN is using https://unpkg.com it can be configured by +While the default CDN is using https://cdn.jsdelivr.net/npm it can be configured by setting the optional `data-jupyter-widgets-cdn` attribute for script tag which loads `embed-amd.js`, as shown in the example above. diff --git a/docs/source/migration_guides.md b/docs/source/migration_guides.md index d9cdb7fc03..7bca591af1 100644 --- a/docs/source/migration_guides.md +++ b/docs/source/migration_guides.md @@ -147,7 +147,7 @@ values of the `version` field in your `package.json`). The `_model_module_version` and `_view_module_version` are used to find your JavaScript bundle when embedding widgets. The embed manager will look for the -bundle at `https://unpkg.com/@/dist/index.js` +bundle at `https://cdn.jsdelivr.net/npm/@/dist/index.js` when it finds a widget. ### Updating embedded widgets @@ -159,7 +159,7 @@ There are now two options for embedding widgets in an HTML page outside of the n If you are just embedding the standard widgets that come with ipywidgets, then you can simply include the following script tag: ```html - + ``` If you want to use a specific version of the embedder, you replace the `@*` with a semver range, such as `@^0.9.0` @@ -175,7 +175,7 @@ In order to embed third-party widgets, you can use the RequireJS-based embedding Then include the following script, which defines the embedding libraries and runs the function to render widgets: ```html - + ``` If you want to use a specific version of the embedder, you replace the `@*` with a semver range, such as `@^0.9.0` diff --git a/examples/web1/manager.js b/examples/web1/manager.js index 1bec8186fc..6a6e7e7dd1 100644 --- a/examples/web1/manager.js +++ b/examples/web1/manager.js @@ -20,11 +20,11 @@ class WidgetManager extends ManagerBase { let failedId = err.requireModules && err.requireModules[0]; if (failedId) { console.log( - `Falling back to unpkg.com for ${moduleName}@${moduleVersion}` + `Falling back to jsDelivr for ${moduleName}@${moduleVersion}` ); window.require( [ - `https://unpkg.com/${moduleName}@${moduleVersion}/dist/index.js` + `https://cdn.jsdelivr.net/npm/${moduleName}@${moduleVersion}/dist/index.js` ], resolve, reject diff --git a/examples/web2/manager.js b/examples/web2/manager.js index 125527fba3..b70e7e0f92 100644 --- a/examples/web2/manager.js +++ b/examples/web2/manager.js @@ -20,11 +20,11 @@ class WidgetManager extends ManagerBase { let failedId = err.requireModules && err.requireModules[0]; if (failedId) { console.log( - `Falling back to unpkg.com for ${moduleName}@${moduleVersion}` + `Falling back to jsDelivr for ${moduleName}@${moduleVersion}` ); window.require( [ - `https://unpkg.com/${moduleName}@${moduleVersion}/dist/index.js` + `https://cdn.jsdelivr.net/npm/${moduleName}@${moduleVersion}/dist/index.js` ], resolve, reject diff --git a/examples/web4/README.md b/examples/web4/README.md index 202bb1c9c9..aac99c69f4 100644 --- a/examples/web4/README.md +++ b/examples/web4/README.md @@ -13,12 +13,12 @@ replace with -`` +`` If you need a specific version of the HTML widget manager, you can include a semver range. For example: -`` +`` ## Try it diff --git a/ipywidgets/embed.py b/ipywidgets/embed.py index 0914a7851b..a8da0d04ed 100644 --- a/ipywidgets/embed.py +++ b/ipywidgets/embed.py @@ -58,8 +58,8 @@ {view_spec} """ -DEFAULT_EMBED_SCRIPT_URL = 'https://unpkg.com/@jupyter-widgets/html-manager@%s/dist/embed.js'%__html_manager_version__ -DEFAULT_EMBED_REQUIREJS_URL = 'https://unpkg.com/@jupyter-widgets/html-manager@%s/dist/embed-amd.js'%__html_manager_version__ +DEFAULT_EMBED_SCRIPT_URL = 'https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@%s/dist/embed.js'%__html_manager_version__ +DEFAULT_EMBED_REQUIREJS_URL = 'https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@%s/dist/embed-amd.js'%__html_manager_version__ _doc_snippets = {} _doc_snippets['views_attribute'] = """ @@ -81,7 +81,7 @@ full description. embed_url: string or None Allows for overriding the URL used to fetch the widget manager - for the embedded code. This defaults (None) to an `unpkg` CDN url. + for the embedded code. This defaults (None) to a `jsDelivr` CDN url. requirejs: boolean (True) Enables the requirejs-based embedding, which allows for custom widgets. If True, the embed_url should point to an AMD module. diff --git a/packages/html-manager/src/libembed-amd.ts b/packages/html-manager/src/libembed-amd.ts index 42a80977c7..14294f895a 100644 --- a/packages/html-manager/src/libembed-amd.ts +++ b/packages/html-manager/src/libembed-amd.ts @@ -3,7 +3,7 @@ import * as libembed from './libembed'; -let cdn = 'https://unpkg.com/'; +let cdn = 'https://cdn.jsdelivr.net/npm/'; let onlyCDN = false; // find the data-cdn for any script tag, assuming it is only used for embed-amd.js @@ -54,7 +54,7 @@ function moduleNameToCDNUrl(moduleName: string, moduleVersion: string): string { * @param moduleName The name of the module to load.. * @param version The semver range for the module, if loaded from a CDN. * - * By default, the CDN service used is unpkg.com. However, this default can be + * By default, the CDN service used is jsDelivr. However, this default can be * overriden by specifying another URL via the HTML attribute * "data-jupyter-widgets-cdn" on a script tag of the page. * @@ -95,7 +95,7 @@ export function requireLoader( * * @param element (default document.documentElement) The element containing widget state and views. * @param loader (default requireLoader) The function used to look up the modules containing - * the widgets' models and views classes. (The default loader looks them up on unpkg.com) + * the widgets' models and views classes. (The default loader looks them up on jsDelivr) */ export function renderWidgets( element = document.documentElement, diff --git a/packages/html-manager/webpack.config.js b/packages/html-manager/webpack.config.js index 0677f63eb1..9e487fe4fc 100644 --- a/packages/html-manager/webpack.config.js +++ b/packages/html-manager/webpack.config.js @@ -56,7 +56,9 @@ var rules = [ ]; var publicPath = - 'https://unpkg.com/@jupyter-widgets/html-manager@' + version + '/dist/'; + 'https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@' + + version + + '/dist/'; module.exports = [ { diff --git a/widgetsnbextension/src/embed_widgets.js b/widgetsnbextension/src/embed_widgets.js index 2ee02bcd3a..7d5ff3c5f2 100644 --- a/widgetsnbextension/src/embed_widgets.js +++ b/widgetsnbextension/src/embed_widgets.js @@ -42,7 +42,7 @@ var embed_widgets = function() { '', '', '', - '', + '', '',