Loading scripts with wp_register_script and wp_enqueue_script

There are probably various ways to do this – personally I use the following for loading some small scripts only on the “new” and “edit” pages (datepicker etc.):

function load_my_admin_scripts( $hook ) {

    if (( $hook == 'post.php' || $hook == 'post-new.php' )) {

    wp_enqueue_script(
        'my-datepicker', // name / handle of the script
        SCRIPTS . 'script.js', // path to the script
        array( 'jquery', 'jquery-ui-datepicker' ), // array of registered handles this script depends on
        '1.0', // script version number (optional)
        true // enqueue the script before </head>
    );

    }

}

add_action( 'admin_enqueue_scripts', 'load_my_admin_scripts' );