Refactor (2/N): move inline app script into js/app.js#23
Merged
Conversation
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>
There was a problem hiding this comment.
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>fromindex.htmlinto newjs/app.js(no code changes). - Replace inline block with
<script src="js/app.js">at the same<head>position. - Add
js/**/*tobuild.filesinpackage.jsonto 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second step of splitting the large
index.html.This PR
<script>intojs/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 torenderer.js, the inline version script, and the body is identical — and it keeps the shared global scope the 49 inlineonclick=handlers depend on.js/**/*to thebuild.filesallowlist so the packaged Electron app ships it.index.htmlis now 571 lines (markup + script/link tags), down from 5,931 before the refactor began.Testing
node --check js/app.jspasses.package.jsonvalidates.npm startto confirm the app behaves exactly as before (load a molecule, open the XYZ/ElemCo/orbital panels).Next
Carve
js/app.jsinto 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 (vardeclarations, theInfoobject,$(document).ready/addEventListenerregistrations) will be kept in load order so behavior is preserved.🤖 Generated with Claude Code