Using loadUrl() while requiring both vendor JS files, as well as my own


#1

Hello there!

Quick question that I can’t seem to find online. I’m looking to use the loadUrl() function to bring my web app into an Electron window, however there are a pile of js files I need to include in order for it to work. This includes both vendor js files (like jQuery, _, etc.), as well as my own js modules. Where would I include such files? Index.html or app.js (or create a separate js file and require them there)?

Any examples would be immensely helpful, thanks for the help!


#2

Any stuff you would normally include in client side (jquery being an example) are things you would include in the renderer (HTML). Treat the rendered HTML document exactly like a normal web page. Put the script tags in the HTML and include jquery.

Myself, I have gulp writing all of the renderer files I need I to one HTML file. Each page has a fat block of CSS on top and js on the bottom. I don’t have to worry about slow load times because there are no http requests.


#3

As @sameaton11 said you can just use script tags in your index html file. What I do is using a grunt/gulp task to copy all my assets into my electron app and then use relative paths into my HTML file to load them.


#4

Awesome, thanks! Both answers were very helpful.