The background/context of the question is that I’ve been trying to use an extension and a native C application to behave like a single-page desktop application that can run without being connected to the internet.
The browser serves as the user interface and, of course, for all internet functions when the user chooses to do so, and the C application is compiled with SQLite and handles the databases and interacts with the local file system in a manner that limits what it can reach, in the event someone hijacks the extension, if that is possible.
The user opens a local, empty HTML file into which the extension injects the CSS and JS files, which build all the UI components as instances of objects as needed. It is finally working well and I’m surprised at how quickly things can run and communicate between the extension and C program. If I had known this a couple years ago, I could have saved a lot of time and struggle.
Now that the operating structure is in place, I’m able to add in the code from all the individual components I’ve made as I fumbled and stumbled along the way; and that leads to the question.
The content script is growing in size quite a bit as the pieces are assembled. It’s a little over 1 MB and it might be close to 2 MB by the time it’s complete. The background script is kept as small as possible and primarily acts as a telephone operator between the content script and C program.
Should the content script be broken into separate smaller scripts, like header files in a C program? Is it okay to inject five smaller scripts when the extension loads, or better to keep it as one large script?
At 1 MB, it doesn’t seem to be an issue for the browser at all; it loads quickly and performs quickly. Is there a way to handle larger scripts that is best for browser performance?
I read a little about JS modules but that doesn’t appear to pertain to injecting scripts from an extension into a web page; but perhaps I am misunderstanding.