custom page url slug needs illegal ?id=1 for javascript

Here’s a potential solution using the page_link filter and testing for the presence of a meta key to add a query arg:

function wpa84303_page_query_arg( $permalink, $page, $sample ) {
    if( $query_arg = get_post_meta( $page, 'query_arg', true ) )
        $permalink = add_query_arg( 'id', '0', $permalink );
    return $permalink;
}
add_filter( 'page_link', 'wpa84303_page_query_arg', 10, 3 );

Add a custom field to the page with the key query_arg and give it any value, if the key exists then ?id=0 will be appended via the add_query_arg function.