How to load absolute CSS and JS assets I would like to load CSS and JS from https://static.example.com . The typical page contains:

&lt;link rel="stylesheet" href="/sites/default/files/css/css__wBfhyL83sORKzo__AgHv4HOGuOoSbIzIaa4clq9PXs.css?pik02l" media="all" /&gt;


and contains similar entries for JS.  I would like to add https://static.example.com to the front of the href="URL" for both CSS and JS.

I'm am aware that this can be done with a contrib module.  I would like to find a hook or some other way to add this to my custom module.
Even though you don't want to use a contrib module I will recommend the CDN module anyways. It does what you want, but if you don't want to use it you can still look at how they do it.

They define a lot of services, but the most interesting one is this one:

cdn.file_url_generator:
    class: Drupal\cdn\File\FileUrlGenerator
    arguments: ['@app.root', '@file_system', '@stream_wrapper_manager', '@request_stack', '@private_key', '@cdn.settings']


The class FileUrlGenerator then does checks for files to determine if they should be rewritten and rewrites them.