Drupal 9 image field migration

Cookiebot auto-blocking mode is not compatible with Drupals JS aggregation as soon as an aggregated file contains the word "cookie", even if it is for removing a cookie, the whole aggregated script is blocked and leads to JS errors like "jQuery is undefined".
We certainly can add addtional attributes to the library files and custom js files, but not for aggregated (in a simple way).
I found really dirty solution how to achieve this result. 
Adding custom method to #pre_render function and checking the SRC of the script if it contains "/js/js_". And simple replace closed tag with data-cookieconsent="ignore".

* Implements hook_element_info_alter().
function mymodule_element_info_alter(array &$types) {
 // Add custom pre_render func to add data-cookieconsent to agregated scripts.
 $types['html_tag']['#pre_render'][] = [\Drupal\mymodule\Element\HtmlTag::class, 'preRenderHtmlTagScript'];

and create mymodule/src/Element/HtmlTag.php file

namespace Drupal\mymodule\Element;
use Drupal\Core\Render\Element\HtmlTag as CoreHtmlTag;
use Drupal\Core\Render\Markup;
class HtmlTag extends CoreHtmlTag {
 public static function preRenderHtmlTagScript($element) {
   if (!empty($element['#attributes']['src']) && strpos($element['#attributes']['src'], '/js/js_') !== FALSE) {
     $prefix = (string) $element['#prefix'];
     $prefix = str_replace('>', ' data-cookieconsent="ignore">', $prefix);
     $element['#prefix'] = Markup::create($prefix);
   return $element;

and that's it. Cookiebot will ignore aggregated files from Drupal and all scripts will continue to work event when user didn't give a consent. But be aware, you should not have any cookies related code there.