Use defer attribute
Instead of converting all script to async as this answer suggested, it's better to use defer. That way, you'll not have dependency errors.
For example, you use a custom script and that script depends on jQuery. Since jQuery is more likely to be bigger than your custom script, it'll probably end loading before jQuery, so your CODE will behave unpredictably.
Instead you can use the following CODE to make sure dependency works:
function js_defer_attr( $tag ){
// add defer to all scripts tags
return str_replace( ' src', ' defer="defer" src', $tag );
}
add_filter( 'script_loader_tag', 'js_defer_attr', 10 );
Here's more about the defer attribute.
Alternative: place script to footer
It's also possible to replace all scripts to footer. Use the following CODE (instead of the above) to place all scripts in the footer:
function move_scripts_to_footer() {
remove_action( 'wp_head', 'wp_print_scripts' );
remove_action( 'wp_head', 'wp_print_head_scripts', 9 );
remove_action( 'wp_head', 'wp_enqueue_scripts', 1 );
add_action( 'wp_footer', 'wp_print_scripts', 5 );
add_action( 'wp_footer', 'wp_enqueue_scripts', 5 );
add_action( 'wp_footer', 'wp_print_head_scripts', 5 );
}
add_action( 'wp_head', 'move_scripts_to_footer', -1 );