Building Blockly
Blockly is made up of over a hundred JavaScript files. Loading these over the Internet is a sluggish experience for end users. To make Blockly load faster, it can be compressed down to half a dozen files totaling about 150kb.
Blockly comes with both the source code and compressed files, so there is no need to build Blockly unless you are hacking in the core, blocks, generators, or msg directories.
Compressing Blockly is extremely simple. Assuming you have Python 2.x installed, just run build.py in Blockly's root directory:
python build.py
This command takes about 20 seconds and uses Google's online Closure Compiler to rebuild several key files:
Compressed Mode
As a result of compression, Blockly can be loaded with a small number of HTTP requests:
Remember that as a developer you probably have a better Internet connection than your users. Compressing the code makes a tremendous difference for users.
Uncompressed Mode
That said, compressed code is simply awful for developers. No JavaScript developer should tolerate a build step between editing code and seeing the result. And no JavaScript developer should have to debug compressed code. When developing Blockly, use uncompressed mode. Let's pull apart the four scripts listed above and find their uncompressed versions:
Core
This one is easy. Just change "compressed" to "uncompressed":
The blockly_uncompressed.js file is generated by the build script and loads all the required core/ and closure-library/ files.
Blocks
If one is hacking the default blocks, replace the compressed blocks file with the original source files:
Generators
If one is hacking the default blocks, replace the compressed blocks file with the original source files (change "javascript" to "python", "php", "lua", or "dart" as needed):
Language
Replace the language file (en, ru, vi, etc) with messages.js:
Playground
When hacking in Blockly's core, the playground is a tremendously useful tool. Just point your browser at tests/playground.html. As a preview, here is the playground on the demo sever. The playground features: