Add attribute to script loaded by the theme

The code referenced in your question is still good. I double checked, and this worked for me:

function wpse_script_loader_tag( $tag, $handle ) {
    if ( 'jquery-fluidbox' !== $handle ) {
        return $tag;
    }

    return str_replace( ' src', ' data-cfasync="false" src', $tag );
}
add_filter( 'script_loader_tag', 'wpse_script_loader_tag', 10, 2 );

(I tested with a different script handle, but that won’t matter):
enter image description here

tech