- Issue created by @ishwar
- 🇺🇸United States ZhuRenTongKu
I know this post is a little old, however, if you're just trying to load the jquery.min.js file from Google's CDN, the following will work. Can be placed in any custom module you've got.
/** * Implements hook_js_alter(). */ function MY_MODULE_js_alter(&$javascript) { $module_handler = \Drupal::service('module_handler'); $advagg_exists = $module_handler->moduleExists('advagg_cdn'); if ($advagg_exists) { return; } // Modified from advagg_cdn module. This module was removed from 6.0 version. // Get JQuery from Google cdn. $jquery_lib = 'core/assets/vendor/jquery/jquery.min.js'; if (!empty($javascript[$jquery_lib])) { $url = 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'; $javascript[$jquery_lib]['type'] = 'external'; $javascript[$jquery_lib]['data'] = $url; $javascript[$jquery_lib]['version'] = '3.5.1'; } }