Hi, I'm trying to build a minimized version of Blockly for use on an embedded device. I'd like to reduce the final JavaScript size as much as possible—ideally under 100 KB as suggested in the official Blockly Advanced Compilation guide.
Create a very small binary of Blockly (ideally ~100 KB or less) to use on a resource-constrained embedded device.
I cloned the latest master branch from Blockly GitHub.
I ran npm run package inside the Blockly directory.
It generated JavaScript files inside build/src/.
I then attempted to run Closure Compiler with the following command:
Note: I removed --externs ../externs/svg-externs.js because the file doesn't exist in the repo.
I get the following errors:
So it seems that Closure Compiler doesn't recognize the goog or Blockly symbols.
What is the correct way to compile Blockly using the Closure Compiler for minimal output?
Where can I find the missing svg-externs.js file mentioned in the documentation?
The doc also refers to core/requires.js—this file no longer exists in the repo. What is the recommended alternative?
Any help or updated instructions would be greatly appreciated. Thanks in advance!
Hi Maribeth,
Thank you very much for your thorough and thoughtful reply — I really appreciate your detailed explanation and the time you took to write it.
To answer your question: yes, I do want to pursue advanced compilation or any other effective method to significantly reduce the size of Blockly. However, the real goal behind this is not just understanding how compression works, but rather obtaining a minimal and optimized build of Blockly that is usable in a highly resource-constrained environment.
Here’s the background:
I’m building a Blockly-based interface that will run on an embedded device mounted on a robot. The embedded device hosts a small web server and serves a Blockly UI to client tablets (like iPads or Android tablets) connected over Wi-Fi. This setup must work entirely offline — no CDN or external assets.
The controller of the embedded system has only 8MB of flash storage (shared with other app components). The pre-built blockly_compressed.js file from the v12.1.0 release is around 1MB, which is quite large for our case.
From my testing, this 1MB file takes about 4–5 seconds to load due to slow I/O on the device. If we could reduce this to 100KB or less, it would not only fit more comfortably in flash, but also reduce load time to under a second — a huge improvement in UX. I am even considering migrating to a 4MB flash chip to reduce manufacturing cost, so minimizing the binary size is essential.
What I’m hoping for is any advice or a path forward to obtain the smallest practical build of Blockly that retains only the features I need (e.g., a limited set of blocks and generators). If that means diving into Closure Compiler configuration, I’m willing to go that route — but if there are examples, templates, or even partial automation (like a script that prunes unused components), that would be incredibly helpful.
Thanks again,
Fumito Sekine
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/0a58534c-93d6-477c-a385-8b45f322f5c3n%40googlegroups.com.