How to defer javascript from within the functions.php file without losing all styling?

I would like to increase performance of wordpress site by deferring javascript on the site. However, when I do this, it loses all styling. Is there a way to be more specific on which styles to render and not?

I’m using the below code in a functions.php file to implement this. It seems to work, but the website loses all of it’s stylings:

Is there a better method I do not know about? Any help is appreciated.