Skip to content

Conversation

alexqhj
Copy link
Contributor

@alexqhj alexqhj commented Feb 25, 2025

Key changes:

  • Updated the return value for non-browser environments and null loader URLs to undefined instead of an implicit return.
  • Simplified script element removal by using the remove method instead of window.document.body.removeChild. Previous version would produce error if the node was not present, i.e. when unloading multiple instances.

@alexqhj
Copy link
Contributor Author

alexqhj commented Feb 25, 2025

Sorry I didn’t open a discussion beforehand. This fix was pretty urgent for our team so I went ahead and (hopefully) patched it. There might be a better approach, but I’m hoping this at least addresses the immediate issue. Would love your thoughts.

@alexqhj alexqhj force-pushed the use-reference-counting branch from 3938add to ea30505 Compare February 26, 2025 10:52
@alexqhj alexqhj changed the title Use reference counting for unity loader hook Use script.remove instead of removeChild for unity loader hook Feb 26, 2025
@alexqhj
Copy link
Contributor Author

alexqhj commented Feb 26, 2025

yeah sorry for the mess. I completely overengineered the issue at first, after spending time debugging. Realized script.remove() would gracefully attempt to remove the node without having to keep references to how many instances of the loader script was initialized.

@jeffreylanters
Copy link
Owner

No problem! Thank you very much for your valuable contributions! I'll releases these improvements soon!

@jeffreylanters jeffreylanters merged commit a22b0b2 into jeffreylanters:main May 15, 2025
3 checks passed
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