Search and Replace Script Loader in Head Only Works in Footer

Can you try this, it was what I tried to explain in my comment. Again, this is just a guess.

function js_async_attr($tag){ 
   // Add async to all remaining scripts
   return str_replace( ' src', ' async="async" src', $tag );
}

add_filter( 'script_loader_tag', 'js_async_attr');

function remove_js_async_head(){
    // function to add async to all scripts
    remove_filter( 'script_loader_tag', 'js_async_attr');
}
add_action( 'wp_head', 'remove_js_async_head', 100);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)