There is a good article on CSSTricks on the Topic and a section on the WP plugin "Asset Queue Manager" which does a similar Job.

https://css-tricks.com/taking-control-cssjs-wordpress-plugins-load/