Skip to content

fix(dx): resolve script loading race conditions in index.html#6530

Open
vanshika2720 wants to merge 1 commit intosugarlabs:masterfrom
vanshika2720:fix/dx-script-loading-race-conditions
Open

fix(dx): resolve script loading race conditions in index.html#6530
vanshika2720 wants to merge 1 commit intosugarlabs:masterfrom
vanshika2720:fix/dx-script-loading-race-conditions

Conversation

@vanshika2720
Copy link
Copy Markdown
Contributor

@vanshika2720 vanshika2720 commented Apr 9, 2026

[DX] Resolve Script Loading Race Conditions in index.html

Type of Change

  • Bug Fix
  • New Feature
  • Documentation

Description

This PR addresses frequent startup console errors ($ is not defined, createjs is not defined, p5 is not defined) by standardizing and consolidating the script loading architecture in index.html.

Key Changes

  1. Consolidated Head Scripts: All external libraries (EaselJS, jQuery, Tone.js, etc.) have been moved to the <head> with the defer attribute. This ensures they are loaded in parallel but executed in a deterministic order.
  2. Standardized Initialization: Inline initialization logic for CreateJS, jQuery plugins, and the Splash Screen has been wrapped in DOMContentLoaded listeners.
  3. Removed Redundant Code: Fixed syntax errors in inline scripts, removed duplicate function definitions (e.g., setIcon, openFullscreen), and eliminated fragmented service worker registration blocks.
  4. Improved Splash Screen: Unified the loading animation logic into a single robust block, ensuring it correctly handles language localization and transitions smoothly.

Value

Dramatically improves the Developer Experience (DX) by providing a "clean" console on startup and making the application initialization sequence robust and easy to reason about. It also improves project reliability across different browsers (especially those with stricter execution timings like Firefox).

Testing Performed

  • Verified script execution order in browser developer tools (Network/Timing).
  • Confirmed $ and createjs are ready when loader.js executes.
  • Validated fullscreen and language dropdown functionality.
  • Ran Prettier to ensure lint compliance in index.html.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions github-actions bot added bug fix Fixes a bug or incorrect behavior documentation Updates to docs, comments, or README size/XL Extra large: 500-999 lines changed area/docs Changes to documentation area/core Changes to core app entry files area/javascript Changes to JS source files and removed area/docs Changes to documentation labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@Ashutoshx7
Copy link
Copy Markdown
Contributor

Ashutoshx7 commented Apr 9, 2026

This.cleanupIdleWatcher() is called in activity.js (2 places), but the method doesn’t exist. It should be this._stopIdleWatcher().
Duplicate cleanup logic for _idleWatcherIntervalId (repeated multiple times).

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from 6b75f71 to cb0b90d Compare April 9, 2026 22:16
@github-actions github-actions bot added size/XXL XXL: 1000+ lines changed and removed size/XL Extra large: 500-999 lines changed labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

activity_listeners.test.js

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from cb0b90d to f69477f Compare April 9, 2026 22:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from f69477f to 5fe9b88 Compare April 9, 2026 22:30
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

WidgetBlocks.test.js

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

WidgetBlocks.test.js

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from df808c9 to d3cf6b9 Compare April 10, 2026 02:03
@github-actions github-actions bot added size/XL Extra large: 500-999 lines changed and removed size/XXL XXL: 1000+ lines changed area/core Changes to core app entry files labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from d3cf6b9 to 7553051 Compare April 10, 2026 04:20
@github-actions github-actions bot added size/M Medium: 50-249 lines changed and removed size/XL Extra large: 500-999 lines changed labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from 7553051 to eaddc28 Compare April 10, 2026 04:43
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Fix jQuery plugin IIFE that was never invoked: the closing `});` meant
the function was defined but never called, so $.fn.fixMe and the
$(document).ready handler never executed. Changed to `})(jQuery);` and
wrapped in a DOMContentLoaded listener with a typeof guard so it waits
for both the DOM and the deferred jQuery script.

Remove broken duplicate script block (lines 1203-1285 on master) that
contained:
- A syntax error (`}} )`) prematurely closing the DOMContentLoaded
  handler after showPersistentNotification
- Duplicate definitions of openFullscreen, closeFullscreen, setIcon,
  and handleFullscreenChange (already defined globally at lines
  1132-1194)
- A duplicate `#installButton.hidden` style block

The working fullscreen functions and the proper play-only-mode script
(at the end of the file) are preserved as-is.
@vanshika2720 vanshika2720 force-pushed the fix/dx-script-loading-race-conditions branch from eaddc28 to c59113a Compare April 10, 2026 07:51
@github-actions github-actions bot added area/core Changes to core app entry files and removed area/javascript Changes to JS source files labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Changes to core app entry files bug fix Fixes a bug or incorrect behavior documentation Updates to docs, comments, or README size/M Medium: 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants