Add crossorigin to Font Awesome Script

<?php
/**
* Frontend scripts & styles
*/
function wd_global_enqueues() {

     // font awesome
     wp_enqueue_script(
          'wd-fontawesome',
          'https://kit.fontawesome.com/0d7904a768.js', // kit is URL restricted
          [],
          null
     );
}
add_action( 'wp_enqueue_scripts', 'wd_global_enqueues' );

/**
* Add additional script attributes
*/
function wd_script_attributes( $tag, $handle ) {

     // add crossorigin to fontawesome
     if ( 'wd-fontawesome' == $handle ) {
          return str_replace( ' src', ' crossorigin="anonymous" src', $tag );
     }

     return $tag;
}
add_filter( 'script_loader_tag', 'wd_script_attributes', 10, 2 );