How to preload a css/js library programmatically after module installation? is there api for changing *.library.yml file? i would like to develop a module where i cached internally html,css,js statically for pages.
1) in a admin setting page i can add a bundle with 1 html page + css/js files.
2) for each bundle i have different path 
3) Normally in drupal8 i can define a file *.library.yml where i can set css/js but in this case is not defined statically when i install the module, but is changed every time in admin section i add a bundle.

Is there drupal API for loading programmatically the register where there are saved libraries and where i can change and save again the configuration? it is not possible do you have other suggestions?
Drupal allows modules to add dynamic library definitions by implementing hook_library_info_build(). Drupal core doesn't implement this hook, except in a test module.

function common_test_library_info_build() {
  $libraries = [];
  if (\Drupal::state()-&gt;get('common_test.library_info_build_test')) {
    $libraries['dynamic_library'] = [
      'version' =&gt; '1.0',
      'css' =&gt; [
        'base' =&gt; [
          'common_test.css' =&gt; [],
        ],
      ],
    ];
  }
  return $libraries;
}


If you instead need to alter the library definitions given from another module, hook_library_info_alter() is the correct hook to use.

function locale_library_info_alter(array &amp;$libraries, $module) {
  if ($module === 'core' &amp;&amp; isset($libraries['jquery.ui.datepicker'])) {
    $libraries['jquery.ui.datepicker']['dependencies'][] = 'locale/drupal.locale.datepicker';
    $libraries['jquery.ui.datepicker']['drupalSettings']['jquery']['ui']['datepicker'] = [
      'isRTL' =&gt; NULL,
      'firstDay' =&gt; NULL,
    ];
  }

  // When the locale module is enabled, we update the core/drupal library to
  // have a dependency on the locale/translations library, which provides
  // window.drupalTranslations, containing the translations for all strings in
  // JavaScript assets in the current language.
  // @see locale_js_alter()
  if ($module === 'core' &amp;&amp; isset($libraries['drupal'])) {
    $libraries['drupal']['dependencies'][] = 'locale/translations';
  }
}