Add the following code to your functions.php file:
function my_enqueue($hook) {
wp_enqueue_script(
'my_script',
get_stylesheet_directory_uri() . '/assets/js/filename.js',
array(),
false,
true
);
}
add_action('admin_enqueue_scripts', 'my_enqueue', 999999);
Where: admin_enqueue_scripts enqueues scripts for all admin pagesmy_enqueue is the name of the function that will handle the desired funcionality.999999 specifies the order in which the function associated with the action is executed. With this high value it’s expected that the insertion code will be done near the end of the file.
And inside the function:'my_script' is the name of the scriptget_stylesheet_directory_uri() . '/assets/js/filename.js' is the path of the filearray() no script dependenciesfalse no script versiontrue enqueues the script before </body>