Hello,
You may try to use this plugin https://wordpress.org/plugins/wp-minify/ for the solution.
Thank you. Regards, Eva Kemp.