|This article has links to websites or programs not trusted by Scratch or hosted by 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. However, projects with large file sizes will take a very long time to load, and there are other restrictions: each costume and sound has a limit of 10 MB and the
project.json file, which contains the project's code, has a limit of 5 MB. If a project reaches one of these two limits, there are several ways to reduce the size.
Sprites and Scripts
There may be large scripts that are repeated multiple times, which may take up lots of data. This can be fixed by creating a custom block or using broadcasts.
Blocks may have text hidden behind a reporter or variable block. If a block contains a large text covered by a reporter block, it's best to remove it by dragging the reporter out, deleting the text, and dragging it back in.
Comments store unnecessary information that isn't needed for runtime, so to reduce the file size, comments may be deleted.
Lists and variables may contain data that is deleted or reset upon clicking the green flag. Before saving the project, clear the specific lists and variables that are reset.
These advanced methods require knowledge about how to access and edit the
Numbers entered into string parameters may be represented as strings in the
project.json file. A small number of unnecessary parentheses could be removed by removing the quotations from the numbers. 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.
Block IDs are typically represented as long strings 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.
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 useless 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.
If a bitmap costume can be shown as a vector image, consider using a vector costume as vector images tend to take up less space.
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.
Unused sound files can be deleted because they take up a lot of space. Common sounds to remove are the other sounds included by default in all sprites.
If a project contains sounds are from one's hard drive, then they can be replaced with a compressed version. One way to compress sounds is to convert them to an MP3 file using this site or anything similar.