Creating an empty page programatically

Add a post meta field to indicate this post is just a redirect when creating it:

$postid = wp_insert_post($newpost);
add_post_meta($postid,'redirect','1');

Check the post meta value and if it is a “redirect post”, just output the post content (javascript redirect):

add_action('wp','custom_maybe_redirect');
function custom_maybe_redirect();
    global $post;
    if (!is_object($post)) {return;}
    $redirect = get_post_meta($post->ID,'redirect',true);
    if ($redirect == '1') {echo $post->post_content; exit;}
}

Though I agree with Sumit you should be able to anything with PHP that javascript can do, but in case you are relying on an external endpoint for the javascript (that is all I can think?) then this should do it.