scratchfoundation / scratchfoundation/scratch-blocks
Investigate Progressive loading of the toolbox
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.8k
- Forks
- 1.6k
- Avg merge
- 4h 51m
- Merged PRs (30d)
- 12
Description
To load scratch-blocks, we parse and render every single block in the toolbox immediately. In Scratch there are currently ~180 blocks in the toolbox (without extensions) which makes loading significantly slower.
Investigate whether we can load the visible blocks first (e.g. the first ~10-20) and defer loading the rest.
Ideas:
- Change the default toolbox to only contain the first 10-20 blocks, then use the Blockly.Xml.appendDomToWorkspace to append the rest in an idleTimeout.
Other thoughts:
IIRC, the way flyout rendering currently works is that it reads all the blocks out of the xml, puts them in the SVG, then moves them to the appropriate place. It'd be great to untangle that so there isn't a separate move step, but I'd try the approach above first to side step that.
What's suggested above would only work on load, but theoretically could be applied to the workspace's updateToolbox method as well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the default toolbox loading path and the flyout rendering flow described in the issue. Examine Blockly.Xml.appendDomToWorkspace and the workspace updateToolbox entry point, then measure initial toolbox loading before and after deferring blocks. Done means visible blocks load first without breaking later toolbox updates or rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100