diff --git a/js/grunt/buildRunnable.js b/js/grunt/buildRunnable.js index d1136aaa3..6015e7f4d 100644 --- a/js/grunt/buildRunnable.js +++ b/js/grunt/buildRunnable.js @@ -288,7 +288,8 @@ module.exports = async function( repo, minifyOptions, instrument, allHTML, brand brand: brand, stringMap: stringMap, htmlHeader: htmlHeader, - scripts: [ xhtmlInitializationScript, ...productionScripts ] + initializationScript: xhtmlInitializationScript, + scripts: productionScripts } ); // dependencies.json diff --git a/js/grunt/packageXHTML.js b/js/grunt/packageXHTML.js index 35c424b89..e061eee75 100644 --- a/js/grunt/packageXHTML.js +++ b/js/grunt/packageXHTML.js @@ -31,6 +31,7 @@ module.exports = function( xhtmlDir, config ) { repo, // {string} brand, // {string} stringMap, // {Object}, map[ locale ][ stringKey ] => {string} + initializationScript, // {string} scripts, // {Array.} htmlHeader // {string} } = config; @@ -41,14 +42,18 @@ module.exports = function( xhtmlDir, config ) { const localizedTitle = stringMap[ ChipperConstants.FALLBACK_LOCALE ][ getTitleStringKey( repo ) ]; + const initializationScriptFilename = `${repo}_initialization_${brand}.js`; + const script = scripts.join( '\n' ); const scriptFilename = `${repo}_${brand}.js`; const xhtml = ChipperStringUtils.replacePlaceholders( grunt.file.read( '../chipper/templates/sim.xhtml' ), { PHET_SIM_TITLE: encoder.htmlEncode( localizedTitle ), PHET_HTML_HEADER: htmlHeader, + PHET_INITIALIZATION_SCRIPT: ``, PHET_SIM_SCRIPTS: `` } ); grunt.file.write( `${xhtmlDir}/${repo}_all${brand === 'phet' ? '' : `_${brand}`}.xhtml`, xhtml ); + grunt.file.write( `${xhtmlDir}/${initializationScriptFilename}`, initializationScript ); grunt.file.write( `${xhtmlDir}/${scriptFilename}`, script ); }; diff --git a/templates/sim.xhtml b/templates/sim.xhtml index 582873f2b..b3c5e4801 100644 --- a/templates/sim.xhtml +++ b/templates/sim.xhtml @@ -15,6 +15,7 @@ --> +{{PHET_INITIALIZATION_SCRIPT}} {{PHET_SIM_SCRIPTS}} \ No newline at end of file