Skip to content

Use data-jupyter-widgets-cdn-only attribute to load modules only from CDN #2792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2020

Conversation

Bobgy
Copy link
Contributor

@Bobgy Bobgy commented Feb 23, 2020

Resolves #2786

This PR's changes are learned from previous similar PR: 8aba183

Hi @jasongrout!
Can you help me review this?

I'm not sure how to test, because if I run yarn test, this fails at build step already in master branch.

@Bobgy
Copy link
Contributor Author

Bobgy commented Feb 27, 2020

@jasongrout Friendly ping

@Bobgy
Copy link
Contributor Author

Bobgy commented Mar 6, 2020

@jasongrout Would you have time to take a look?


// find the data-cdn for any script tag, assuming it is only used for embed-amd.js
const scripts = document.getElementsByTagName('script');
Array.prototype.forEach.call(scripts, (script: HTMLScriptElement) => {
cdn = script.getAttribute('data-jupyter-widgets-cdn') || cdn;
onlyCDN =
onlyCDN || script.getAttribute('data-jupyter-widgets-cdn-only') != null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, Thanks!

@jasongrout
Copy link
Member

Thanks! This looks okay to me. Congratulations on your first contribution to ipywidgets!

@jasongrout jasongrout merged commit f983518 into jupyter-widgets:master Mar 10, 2020
@jasongrout jasongrout added this to the 8.0 milestone Mar 10, 2020
@Bobgy Bobgy deleted the load_cdn_directly branch March 10, 2020 06:55
@Bobgy
Copy link
Contributor Author

Bobgy commented Mar 10, 2020

Thanks @jasongrout for the review!

@lock lock bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Option to let @jupyter/html-manager import js files from cdn directly
2 participants