How do I add inline JavaScript to the footer?
Until Add support for inline JS/CSS with #attached is resolved, you should add a JavaScript file normally as a library defined in a MYMODULE.libraries.yml and then pass your module's config as Drupal settings from PHP to this JavaScript file.

foobar:
  version: VERSION
  js:
    js/myscript.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupal
    - core/drupalSettings


Then in MYMODULE.module add the JS file and pass the config over to JS.

/**
 * Implements hook_page_attachments().
 */
function MYMODULE_page_attachments(array &amp;$attachments) {

  $attachments['#attached']['library'][] = 'MYMODULE/foobar';

  // Pass values from PHP to JS.
  $attachments['#attached']['drupalSettings']['MYMODULE']['lorem'] = \Drupal::config('MYMODULE.settings')-&gt;get('lorem');
  $attachments['#attached']['drupalSettings']['MYMODULE']['ipsum'] = \Drupal::config('MYMODULE.settings')-&gt;get('ipsum');
}


Then in the JS file access them like following.

(function($, Drupal) {
  'use strict';
  Drupal.behaviors.MyBehavior = {
    attach: function(context, settings) {

      $('html').once('MyBehavior').each(function() {

        var lorem = settings.MYMODULE.lorem;
        var ipsum = settings.MYMODULE.ipsum;

        // Do whatever you need to do.
        // ...

      });          
    }
  };
})(jQuery, Drupal);




I just found Inline JavaScript that is in an integration module in the docs. But it also says


  Using any inline JavaScript is highly discouraged. If you can use one of the examples above, please consider those before attempting to
  do this.