(Redirected from Project Compression (3.0))

This article has links to websites or programs outside of Scratch and Wikipedia. Remember to stay safe while using the internet as we cannot guarantee the safety of other websites.
This article or section documents the current version of Scratch (version 3.0). For this article in Scratch 2.0, see Project Compression (2.0). For this article in Scratch 1.4, see Project Compression (1.4).

In Scratch 3.0, the total size of a project is unlimited.[1] However, projects with large file sizes will take a very long time to load, and there are other restrictions:

  • Each asset (costume and sound) has a limit of 10 MB[2]
  • The project.json file, which contains the project's code, variables, and everything else, has a limit of 5 MB.[3]

If a project reaches one of these two limits, there are several ways to reduce the size.

Sprites and Scripts

Unneeded sprites may be deleted. Similar sprites may be replaced with cloning or stamping.

Unneeded scripts and blocks may be deleted. There may be large scripts that are repeated multiple times. Code can be reused with custom blocks or broadcasts.

Block inputs may have text hidden behind a reporter or variable block. This can be removed by dragging the reporter out, deleting the text, and dragging the reporter back in.

Unneeded comments may be deleted.

The content of lists and variables are saved in the project. For those that are reset upon clicking the green flag, they may be cleared before saving to reduce the file size. List monitors also store their own copy of the data and this will only be updated to the list's current contents while the monitor is showing.[4]

Advanced Methods

Note Warning: These methods are advanced and require knowledge about how to access and edit the project.json file. They may break your projects.

Block IDs are typically represented as long strings of random characters in the project.json file. Shortening the IDs to use 1, 2, or 3 characters will shorten the file by a few kilobytes. Variable IDs are stored in a similar manner, so shortening the IDs may also work.

Some block inputs store data as strings in the project.json file. In this case, the quotation marks around numbers can be removed. Additionally, large numbers may be stored as hexadecimal or in scientific notation to further shorten the file. Some blocks interpret Number types and String types differently, such as the costume block. Changing strings to numbers may accidentally break the project if values in the types of blocks mentioned are changed.

Input menu dropdown blocks aren't needed, as the main parent block can simply store the value the menu is holding. This has the effect of making blocks such as switch costume to (dropdown v) appear as switch costume to [not a dropdown]


Backdrops and Costumes

There could also be backdrops or costumes that are not being used. Deleting unused backdrops and costumes will free up space.

Bitmap images can be compressed. If they are from a local computer, they can be compressed externally using a tool like TinyPNG and uploaded. Scratch accepts lossy jpeg files (but make sure the file isn't edited in Scratch, otherwise it gets converted to png)

If a bitmap costume can be drawn as a vector image, consider using a vector costume as vector images tend to take up less space.[citation needed]

If this is not possible, the image can be scaled down and back up, but that may cause unwanted pixelation.

Vector images can be further reduced in size by removing (and possibly replacing) excessive details such as windows on a building or fur on a hairy monster. Vector may also be compressed externally using a tool such as Nano.

Sounds

Unused sound files can be deleted because they take up a lot of space. Deleting them can reduce the project's size.

If a project contains sounds from one's hard drive, they can be replaced with a compressed version. One way to compress sounds is to convert them to an MP3 file using a third-party site.

See Also

References

  1. Flowermanvista. (8/8/2019). "It's worth noting that these are the only size limits - there is no limit on overall project size." topic:366461
  2. Flowermanvista. (8/8/2019). "No asset can exceed 10 MB." topic:366461
  3. Flowermanvista. (8/8/2019). "The project.json file cannot exceed 5 MB." topic:366461
  4. awesome-llama. (2024-06-26). "Scratch stores 2 copies of the list." topic:768412
Cookies help us deliver our services. By using our services, you agree to our use of cookies.