Filter irrelevant libraries before building the cache ID.
1 unresolved thread
Closes #3443108
Merge request reports
Activity
229 229 $theme_info = $this->themeManager->getActiveTheme(); 230 // Add the theme name to the cache key since themes may implement 231 // hook_library_info_alter(). Additionally add the current language to 232 // support translation of JavaScript files via hook_js_alter(). 233 230 $libraries_to_load = $this->getLibrariesToLoad($assets); 234 $cid = 'js:' . $theme_info->getName() . ':' . $language->getId() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) (count($assets->getSettings()) > 0) . (int) $optimize; 235 231 232 // Collect all libraries that contain JS assets and are in the header. 233 // Also remove any libraries with no JavaScript from the libraries to 234 // load. 235 $header_js_libraries = []; 236 foreach ($libraries_to_load as $key => $library) { 237 [$extension, $name] = explode('/', $library, 2); 238 $definition = $this->libraryDiscovery->getLibraryByName($extension, $name); 239 if (empty($definition['js'])) { 240 unset($libraries_to_load[$key]); btw it will be slightly faster to populate new array instead of re-indexing array in the loop, moreover it can get rid of
array_values()
at the endEdited by Andrey Postnikov
added 1 commit
- b4fbe760 - Optimize CSS case too and improve unit test coverage.
added 1 commit
- 099db8ea - Remove unneeded array item from data provider.
Please register or sign in to reply