Configure WordPress to Generate Scheme-less Relative URLs

You can use the style_loader_src and script_loader_src filters.

namespace WPSE;

\add_filter( 'style_loader_src' , __NAMESPACE__ . '\protocol_relative-url' );
\add_filter( 'script_loader_src', __NAMESPACE__ . '\protocol_relative-url' );

function protocol_relative_url( string $url ) : string {
  return str_replace( [ 'http:', 'https:' ], '', $url );
}

/* Notes:
 * Namespaces require PHP > 5.3
 * [] array syntax requires PHP > 5.4
 * String type declaration requires PHP > 7.0
 */

error code: 523