You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you try to access a named property of an Object in JavaScript, either by subscripting (foo["bar"]) or by dot notation (foo.bar), you'll either get the value of the property, or undefined if the property doesn't exist - you don't get a KeyError or anything like that. If you were checking if a property was true or not, you'd get the same result whether it existed with a false value, or if it didn't exist at all. We can take advantage of this to eliminate some unnecessary properties in project.json.
In my testing, the block properties "inputs", "fields", "shadow", and "topLevel" can all be excluded if they have false/empty values. This can save up to 52 bytes per block (plus ~3 extra bytes for the commas and all that).
I tested it on Paper Minecraft, and made sure that it worked properly in both online and desktop Scratch after my optimizations - here were my results:
Before compression: 4,835,853 bytes (92.2%)
After compression with ProjectJsonMinimizerNew: 3,538,267 bytes (67.5%)
After further compression: 2,855,259 bytes (54.5%) (~20% further size reduction)
Obviously, the results would be even more dramatic on projects that are more code-heavy and less data-heavy.
The text was updated successfully, but these errors were encountered:
Interesting. I thought that something like this may be possible but I haven't really experimented with it.
One of my original goals when making minimizer was: if some unofficial tool can handle 100% of scratch projects created with original scratch editor, it shouldn't break when dealing with compressed projects. Even though scratch itself is fine with some properties missing, if scratch can't produce such projects, then I can't assume that other tools are designed to handle it.
I will still probably implement it in a separate "Dangerous" section or something
When you try to access a named property of an Object in JavaScript, either by subscripting (
foo["bar"]
) or by dot notation (foo.bar
), you'll either get the value of the property, orundefined
if the property doesn't exist - you don't get a KeyError or anything like that. If you were checking if a property was true or not, you'd get the same result whether it existed with a false value, or if it didn't exist at all. We can take advantage of this to eliminate some unnecessary properties in project.json.In my testing, the block properties "inputs", "fields", "shadow", and "topLevel" can all be excluded if they have false/empty values. This can save up to 52 bytes per block (plus ~3 extra bytes for the commas and all that).
I tested it on Paper Minecraft, and made sure that it worked properly in both online and desktop Scratch after my optimizations - here were my results:
Before compression: 4,835,853 bytes (92.2%)
After compression with ProjectJsonMinimizerNew: 3,538,267 bytes (67.5%)
After further compression: 2,855,259 bytes (54.5%) (~20% further size reduction)
Obviously, the results would be even more dramatic on projects that are more code-heavy and less data-heavy.
The text was updated successfully, but these errors were encountered: