Skip to content

Conversation

@mzgoddard
Copy link
Contributor

Proposed Changes

Dynamically load the 1.6MB of music extension sample files dynamically.

Reason for Changes

Split the music extension samples to be loaded separate from the main scripts to need less to be downloaded and for faster first execution of those scripts so Scratch starts earlier.

This change uses webpack's chunking to dynamically load the music extension files. An improvement would be to fetch the files as data through fetch/xhr base64 encoded json content or as a sound sprite.

Dynamically loaded separate from the main scripts, music samples could be preloaded with a script tag, in this format, or with an audio or link tag in the html body if it was encoded in a json file or sound sprite. This would load the file near the same time of the main scripts without blocking their execution.

Copy link
Contributor

@rschamp rschamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mzgoddard, I think this looks good, just some comments would be helpful.


if (!assetData[fullPath]) return;
return this._fetchSounds()
.catch(() => ({}))

This comment was marked as abuse.

This comment was marked as abuse.

_fetchSounds () {
if (!this._assetData) {
this._assetData = new Promise((resolve, reject) => {
require.ensure([], () => {

This comment was marked as abuse.

This comment was marked as abuse.

@mzgoddard mzgoddard force-pushed the dynamic-load-music branch from da53956 to ff7b575 Compare May 4, 2018 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants