Load libraries from the jsDelivr CDN. jsDelivr is a CDN service that load open source web assets from multiple CDN from over 80 locations. A community contribution from https://dxpr.com/
I created this module because I think it's a great alternative to loading local libraries and jsDelivr has some cool features, like fuzzy version specification and loading multiple libraries in one request. Patches for improvement are welcome.
Usage with GUI:
Enable module, it has no dependencies. You can enter JS and CSS libraries in the configuration form at Configuration > Web Services > jsDelivr.
Usage with API functions:
You may also add libraries programmatically by using the utility functions jsdelivr_detect and js_delivr_add.
It's important to understand the for JS libraries we use the /g/ API, which supports version aliases and partial version specification (e.g. latest 3.x or latest 1.2.x). For CSS we only support adding complete file paths, because while using the /g/ API you loose any assets that are specified in the library using relative paths.
Example:
module_load_include('module', 'jsdelivr');
if (function_exists('jsdelivr_detect') && (jsdelivr_detect('flexslider') == FALSE))) {
jsdelivr_add_js('flexslider@2');
}
The above code checks if there is any occurence of Flexslider in the library list and if there is not it adds the latest Flexslider 2.x version.
For more info about jsDelivr version aliases see: https://github.com/jsdelivr/jsdelivr#version-aliasing
Reald world example loading multiple libraries:
/**
* Implementation of hook_init().
*/
function sooperthemes_basic_shortcodes_init() {
module_load_include('module', 'jsdelivr');
if (function_exists('jsdelivr_detect')) {
if (jsdelivr_detect('animatecss') == FALSE) {
jsdelivr_add_css('animatecss/3/animate.min.css');
}
if (jsdelivr_detect('fontawesome') == FALSE) {
jsdelivr_add_css('fontawesome/4/css/font-awesome.min.css');
}
if (jsdelivr_detect('wow') == FALSE) {
jsdelivr_add_js('wow@1');
}
}
}
Project information
Unsupported
Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projectsObsolete
Use of this project is deprecated.- Project categories: Integrations
28 sites report using this module
- Created by jurriaanroelofs on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
