Skip to content

Refactor (2/N): move inline app script into js/app.js#23

Merged
dnkats merged 1 commit into
mainfrom
refactor/extract-app-js
May 31, 2026
Merged

Refactor (2/N): move inline app script into js/app.js#23
dnkats merged 1 commit into
mainfrom
refactor/extract-app-js

Conversation

@dnkats

@dnkats dnkats commented May 31, 2026

Copy link
Copy Markdown
Member

Second step of splitting the large index.html.

This PR

  • Moves the ~4,120-line inline <script> into js/app.js, loaded via <script src="js/app.js"></script> at the same position in <head>. Pure move, no code changes. Because it's a classic (non-module) script loaded in the same document position, execution order relative to renderer.js, the inline version script, and the body is identical — and it keeps the shared global scope the 49 inline onclick= handlers depend on.
  • Adds js/**/* to the build.files allowlist so the packaged Electron app ships it.

index.html is now 571 lines (markup + script/link tags), down from 5,931 before the refactor began.

Testing

  • node --check js/app.js passes.
  • package.json validates.
  • Recommend a quick npm start to confirm the app behaves exactly as before (load a molecule, open the XYZ/ElemCo/orbital panels).

Next

Carve js/app.js into per-feature files (js/jsmol-setup.js, js/selection.js, js/orbitals.js, js/xyz-editor.js, js/elemco.js, js/xtb.js, js/search.js, js/preferences.js, …) as classic scripts in dependency order — each a JS-only diff, much easier to review now that it's out of the HTML. The interleaved top-level state (var declarations, the Info object, $(document).ready/addEventListener registrations) will be kept in load order so behavior is preserved.

🤖 Generated with Claude Code

Second step of splitting index.html. Pure move: the ~4,120-line inline
<script> is now js/app.js, loaded via <script src="js/app.js"> at the
same position, so execution order (relative to renderer.js, the version
script and the body) is unchanged. index.html is now ~570 lines of
markup. Add js/**/* to the electron-builder files allowlist.

Follow-up PRs will carve js/app.js into per-feature files.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 31, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This is the second step in splitting up a large index.html. It extracts the ~4,120-line inline <script> block verbatim into a new js/app.js file, loaded with a <script src="js/app.js"> tag at the same position in <head>. Because the script remains a classic (non-module) script loaded at the same point in the document, execution order and shared global scope are preserved — important since 49 inline onclick= handlers rely on those globals. The package.json build.files allowlist is updated so the new directory ships in packaged Electron builds.

Changes:

  • Move inline <script> from index.html into new js/app.js (no code changes).
  • Replace inline block with <script src="js/app.js"> at the same <head> position.
  • Add js/**/* to build.files in package.json to include the new directory in builds.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
index.html Removes the large inline script and replaces it with an external reference to js/app.js.
package.json Adds js/**/* glob to electron-builder's files allowlist so the new script is packaged.

@dnkats dnkats merged commit 4f60f48 into main May 31, 2026
1 check passed
@dnkats dnkats deleted the refactor/extract-app-js branch May 31, 2026 15:38
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

Successfully merging this pull request may close these issues.

2 participants