Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move most or all of chipper-startup.js to a preload #773

Open
samreid opened this issue Jul 12, 2019 · 6 comments
Open

Move most or all of chipper-startup.js to a preload #773

samreid opened this issue Jul 12, 2019 · 6 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Jul 12, 2019

From #764

I said:

(8) Is there a way to get (almost all of) chipper-startup.js to run as a standard preload, referenced from chipper/build.json? That would help unify this new code with existing code, and get rid of the code like this:

  const startupJS = grunt.file.read( '../chipper/templates/chipper-startup.js' );
  const productionStartupJS = minify( startupJS, minifyOptions );
  const debugStartupJS = minify( startupJS, debugMinifyOptions );

Moving toward this strategy may help us reach the goal of running this new code in requirejs + built mode?

@samreid
Copy link
Member Author

samreid commented Jul 12, 2019

@jonathanolson replied:

There is definitely opportunity for simplification (I'm including some cleanup in the above commit). We independently minify the four of these in both production and debug ways: ...productionPreloads, productionStringsJS, productionJS, productionStartupJS. The strings JS (chipper-strings.js) is only for built mode, as we have a different way of loading strings in require.js, so I don't feel like there is a fully unified approach.

@samreid
Copy link
Member Author

samreid commented Jul 12, 2019

This seems related to #769. I agree that custom logic is needed for productionPreloads, productionStringsJS, productionJS, productionStartupJS, but I'm not seeing why (almost all?) of chipper-startup.js shouldn't be in a preload. What are the drawbacks of making it a standard preload? Can this be investigated further?

@samreid
Copy link
Member Author

samreid commented Jul 12, 2019

@jonathanolson also said in slack:

Scenery itself (and standalone builds) don’t have preloads, so it would take some larger architectural build challenges to get that to work (but that I could look into)

@jonathanolson
Copy link
Contributor

So I realized that Scenery won't need chipper-startup, so I believe we can ignore my previous comment!

It's possible to rewrite sim-development.html so that it calls loadURL on chipper-startup.js, however it's important to note that this CANNOT be a "preload" in general, because in the built form, it needs to be run AFTER the require.js script is executed, and would be more of a "postload".

@jonathanolson
Copy link
Contributor

The branch above has a commit that has the require.js startup mode also use chipper-startup.js. @samreid what are your thoughts on it? Commit is f30b263

@samreid
Copy link
Member Author

samreid commented Jul 27, 2019

The change set looks great and works nicely, but I noticed around a 120ms delay in the startup time using this patch. This is a short amount of time, but it's longer than I expected. I still think we should proceed with this, but was surprised by the 120ms and wanted to run it past you.

UPDATE: to clarify, I measured this time by putting Date.now() right before loading chipper-startup.js and right at the beginning of the runRequireJS callback.

@samreid samreid assigned jonathanolson and unassigned samreid Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants