Prevent direct access to WordPress plugin assets?

so you need to make sure you are using the hook “admin_enqueue_scripts”. this only loads the script on the admin side.
admin_enqueue_scripts is the proper hook to use when enqueuing scripts and styles that are meant to be used in the administration panel. Despite the name, it is used for enqueuing both scripts and styles.

you can find more about the function here https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/

Hope this was helpful.

tech