"document is too large to save" error pops up when saving an app in slate

I have made some changes in the app, and while saving it is throwing error that document is too large to save please remove some data, if I leave the page all the changes I made will be reversed, any solution for this

Slate saves the application configuration as a JSON document, which generally has a size limit of 2,000,000 bytes of UTF-8 encoded characters. Attempts to save a Slate application with a configuration above the size limit will fail, and changes will need to be made to the application configuration to decrease the size. The JSON document of an opened Slate application can be retrieved through export.

Every part of a Slate application takes up configuration size to some degree, and editors should be conscious about both the scale of Slate applications being built, and the resources being embedded in the application configuration. The following are prevalent reasons for the overuse of configuration size, along with proposed solutions:

Base64 encoded images

Upload the image to Foundry and reference the image using the Image widget.

Large functions

Consider refactoring functions to extract common logic into function libraries.

Additionally, large functions may be better suited as Foundry Functions consumed via the Platform editor.

Large function libraries

While function libraries are shared across all pages of a Slate application to conserve space, javascript libraries can be quite large. Either refactor custom libraries to use shared logic, or use minified versions of external libraries.