Managing Coded Sites, Pages, and Elements

When working on a Wix site with code, it's important to understand how duplication and deletion affect your site's functionality. Whether you're copying an entire site, a page, or an individual element, or deleting elements with connected code, the outcome depends on how your code is structured and wired.

Duplicating pages and sites

You can duplicate sites and pages, as well as clone and transfer your Wix sites. Whether you're duplicating a single page, an entire site, or cloning or transferring a site, the code and events are maintained in the new version.

Duplicating elements

When you copy and paste an element that has associated code, the element itself is duplicated, but any events, wiring, or code linked to it aren't included.

Important: If you're building a Wix site that others can edit, make sure they understand the limitations of working with elements. For more information, see Working with Collaborators.

Deleting elements

When you delete elements from your site, the behavior of any associated code depends on the type of event handler used — static or dynamic. In both cases, the code itself isn't automatically removed, but how it's connected to the element changes.

Note: In the editor, if a collaborator tries to delete elements referenced by code, a confirmation prompt displays. The prompt helps prevent accidental deletions that can impact your code. The prompt displays for:

  • Elements directly referenced by code. A code icon displays for these elements as an indicator.
  • Parent elements whose nested elements are referenced by code.

Deleting an element with dynamic event handler

When you delete an element with a dynamic event handler, the associated code isn't removed. If you add a new element and give it the same ID as the deleted one, the existing code will continue to work as expected.

Deleting an element with static event handler

When you delete an element with static event handler, the associated code remains, but the event wiring is removed. For example, you have an element named button2 with an onClick event that toggles the visibility of an element called image3:

Copy

If you delete button2 from your page, the event code is not deleted. However, the event is no longer wired. This means that if you add a new button and name it button2, the code above won't run when it's clicked, you would need to rewire the event manually.

See also

Did this help?