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
WIP: Smarter cdn #1676 #1678
WIP: Smarter cdn #1676 #1678
Conversation
Having #1680 would make this possible by making sure bundles are built after |
We could easily avoid dependency injection by using |
import subprocess | ||
|
||
links = {} | ||
data = subprocess.check_output(['links', '-dump', 'https://cdnjs.com/']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not have to scrape the website. There is a nice .json file we could use with a little parsing (might need an input format change to account for different files and versions): https://github.com/cdnjs/cdnjs/wiki/Extensions%2C-Plugins%2C-Resources#developers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be some config with an array of which libraries to include. Hard-coding a few into the default themes is not really flexible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aeyoun I don't understand. The list of available libraries cdnjs supports is quite extensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ralsina, but there is no setting to tell Nikola what libraries to load. Each library is hardcoded in the theme and not loaded based on a configurable setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aeyoun I always assumed the theme author chooses what he loads...
This is probably colorbox translations’ fault. I suggest using string formatting, like this (untested): cdn_url('jquery.colorbox::i18n/jquery.colorbox-{lang}.js',
use_cdn,
'/assets/js/colorbox-i18n/jquery.colorbox-{lang}.js',
lang=colorbox_locales[lang]) (using |
…ke requiring webassets when not using it, maybe template error syntaes
This approach is not convincing to me anymore. I'll explore alternatives. Maybe using browserify + requires for "bundling" JS instead of webassets. And https://github.com/jfhbrook/browserify-cdn as the CDN alternative. |
Try to be smarter and automatically use a CDN (or not) without having to do complex code in the templates.