The is_admin()
function is basically used to check whether the running request is routing on /wp-admin/. Calling the is_admin() conditional function, you can restrict files you only want to load when a request goes through the /wp-admin/.
Note that is_admin() and is_super_admin() are not the same and both handle different conditions.
Looking forward, when sending an ajax request, it goes through the /wp-admin/ folder, so it would be nice to do:
if ( is_admin() || wp_doing_ajax() ) { // code here }
Talking about best usage, I would say optimization, efficiency, and speed. Loading the entire class files
at once by doing if ( is_admin() ) { ... }
is never a good practice. You should also extend the check to an independent action that requires a condition. For example:
if ( is_admin() ) { require_once '/path/to/file/'; if ( $_GET['type'] ?? false ) { include_once '/path/to/another/file/'; } }