Toggle Sidebar Display

While annoying, your plugin is functioning properly. The page completely renders itself first, showing the sidebar, and then the JavaScript code activates to hide the sidebar.

The fix for this is to have your PHP code check/grab the user’s cookie and set the display’s sidebar status accordingly. That way when the page renders it will be set to none initially, and then any future image toggles can hide/show the sidebar dynamically.

When the page is loaded again for whatever reason, the same PHP loading code will run again, and set the initial state of the sidebar accordingly, without any need to “follow up” after the initial page load to show/hide the sidebar.

Hopefully this makes sense. If you need some specifics, you might try updating your question with the code involved.