-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] Alternative script for patching the user's html file #52
Comments
FWIW, this is probably more subtle/advanced than it needs to be. Instead of creating a document fragment from a string using a range, it should be possible to simply create a script element DOM object with |
@ScottFreeCode the problem with that idea is that most browsers will not execute or try to download that script, unless it is added the way I did. See the stackoverflow link |
From that Stack Overflow question https://stackoverflow.com/q/57209520 :
From the accepted answer on the same question https://stackoverflow.com/a/57211379 :
The difference is use of This is also used in long-established web frameworks that predate ES Modules and as far as I know work cross-browser, and which still work today (I used it with Chromium just a couple weeks ago): e.g. https://requirejs.org/ (and there's a good discussion of possible implementations here https://requirejs.org/docs/why.html ) |
That said, I just tried ES Modules and they seem to work fine in a page served by Neu. If you don't specifically want to embed scripts complete with text content right in the page source rather than from JS files, or to load scripts synchronously for some reason, then ES Modules is probably the way to go. It's been a long time since they were experimental and everyone was bugging various frameworks and libraries to support them even though runtimes like Node didn't yet; I'd expect them to be pretty much the go-to solution now for anything with a server (even if the server is really just a local app!) |
I didn't really like the idea of having neutralino patching my html file, so I decided to create this script, which I put in my public folder:
I am using react (cra) as my frontend, so somewhere in my
index.html
file, I placed the following:Problems immediately solved
Potential future solution
Include this script as part of the
neu create myapp
process. I suggest changing the meaning offrontendLibrary.patchFile
from being the file thatneutralino
will patch, to meaning the location where neutralino will place the above patch script:The text was updated successfully, but these errors were encountered: