Summary: Sometimes, removing a web part from a SharePoint page really hides or disables it but doesn't really delete it. The web part sits in a hidden recycle bin, which can cause some problems. This article explains how to use Web Part Page Maintenance to really delete a web part.
Sometimes you need to remove web parts from your SharePoint page. This seems like a typical, everyday thing for a Site Owner to have to do. And it is. But a successful web part removal depends on the situation, how you remove the web part, and why you’re doing it. The thing is, removing a web part in SharePoint isn’t always as simple as it seems. And in some unique situations, you want to make sure you’re doing it right so you can avoid unexpected annoyances along the way.
The major takeaway from this post is that in SharePoint 2013 and earlier versions, when you delete a web part, sometimes it doesn’t get fully removed; a dormant version lives in a sort-of web part recycle bin.
Similarly, in SharePoint 2016 and SharePoint Online, web parts end up in their recycle bin if you close a web part. So even if you think you got rid of these web parts, they’re still stored in a back room in SharePoint. It’s kind of tricky. And I’ll cover how to deal with the situation below.
Why deleting web parts makes sense
SharePoint gives you three ways to remove or hide a web part:
- Minimize: Useful if you want to “close up” a web part temporarily. The web part’s title is still visible on the page, so you can tell the web part is still there; the web part’s just not taking up much screen space, which can be useful in certain situations. It’s kind of like the plus sign that pops up when you group items in a list that lets you expand/close lower items.
- Close: Similar to delete, but the web part still exists on the page, even though you (and your users) aren’t really aware of it. It basically hides the web part so nobody sees it on the page itself, in a dormant state.
- Delete: The web part is completely removed from the page, at least in SharePoint 2016 and SharePoint Online. (Note: In my experience, this sometimes functioned identically to a “close” in SharePoint 2007 and SharePoint 2013. I’m sure it’s not a random occurrence, but I never figured out the pattern of why it did which when it did.)
But, generally, clicking Delete on a web part will do what you need it to do.
Figure 1: On a new site, many Site Owners delete the default web part
Problems you can face removing web parts
As mentioned above, if your web part includes code, it could cause an unexpected error that makes the page unresponsive, affecting the ability to continue editing the page, adding or removing web parts, or doing basically anything else. It’s kind of a living hell for a dedicated SharePoint Site Owner.
The other major issue is SharePoint’s well-documented threshold of 25 web parts max on any SharePoint page. “Threshold” is a technical term of Microsoft’s and it basically means “recommended number you shouldn’t exceed.” Any time you go over that, the load time on the page could get slow. Why might this affect you? If you typically close web parts rather than delete them, the web parts don’t actually leave; as you add new web parts, you’re stacking the total parts on a page, potentially bringing you close to—or exceeding—the maximum threshold of web parts.
This could also impact you when you delete web parts in SharePoint 2007, 2010, and 2013. As mentioned above, I couldn’t ever figure out how SharePoint made the decision, but it seemed some deleted web parts were stored as if they were closed, while others were deleted as intended.
How to fully remove the web parts
The only way to fully remove the web parts that you close (SharePoint 2016 and SharePoint Online) or sometimes close (SharePoint 2007, 2010, 2013) is to go through an annoying little back door to a SharePoint page that you likely don’t know about. It’s basically a recycle bin for web parts on a given page, and each page has this secret recycle bin. It’s called the Web Part Page Maintenance page.
And how do you get to it? Add ?Contents=1 to the end of the page address.
Yes, this will work in any on-prem SharePoint environment, not just SharePoint Online (the example I used above). Also, as a reminder, the ?Contents=1 must follow the page name ending in .aspx. Otherwise you’re not calling out the contents of that page.
And this is the page that comes up:
Figure 2: The Web Part Page Maintenance page shows two Document libraries but one is not open on the page
In this example, my home page has three web parts. First is the Newsfeed (Site Feed, seen above). The second and third are the default Documents library, displayed twice. I added the library once, then closed it. Because it appears it was missing, I added it again in the same web part zone (a mistake that is easy to make by both a new and veteran Site Owner). So I actually have three web parts on this page, even though only two display. See the actual page (with my commentary) below.
Figure 3: Three web parts, one is a hidden Documents library
From the Web Part Page Maintenance page, you can delete web parts by checking the appropriate box and clicking Delete. The closed or deleted web parts (depending on SharePoint version, as mentioned above) are the ones that display as “No” under “Open on Page?”. Be careful though: you’re removing web parts from the background and you likely cannot undo this operation. You can also close web parts from this page. I’ve never personally used the Reset option but Microsoft has documented its purpose here.
Now, it would be nice to say that it happens this way all the time, but it’s not the case as far as I’ve seen. Sometimes after you close a web part and re-add it, the title of the new web part gets a  after it, which makes sense (like "Documents ", as would happen if you added the same web part twice on the same page). But sometimes (as shown above) it doesn’t do that. I have found no pattern there. Also, sometimes you get the close option in the edit web part drop-down list, but sometimes you don’t. I again have found no pattern there.
Although rare, you may sometimes have an issue requiring you to go into the Web Part Page Maintenance page to, well, empty your web part recycle bin for lack of a better term. This is especially useful if you’ve screwed up some code in a Content Editor Web Part or Script Editor Web Part. It’s also useful when you’ve overused the close or delete option for your web parts and end up exceeding Microsoft’s suggested maximum of 25 web parts per page in SharePoint.
This is another subtle thing that SharePoint does that you likely don’t even know about, that is until your untimely discovery when it really matters. Unless, of course, you read this ahead of time and keep it in mind going forward.
Matt Wade regularly posts on his blog at icansharepoint.com. Follow him @thatmattwade for more SharePoint tips and tricks.