Yes, those lines are part of your View Cart button code, and are required to manage the overlay-style cart inside your page. Just make sure you have at least one complete block of View Cart code (or at least that section you referenced) on every page that has any number of Add to Carts.