|
From: Robert H. <ha...@st...> - 2020-12-10 03:28:16
|
On Wed, Dec 9, 2020 at 6:25 PM Mark Perri <pe...@so...> wrote: > Hi Bob, > > I've been experimenting with bundling the Jmol-SwingJS and JSmol files to > speed up loading. Jmol-SwingJS took 33 seconds to load because it loads > each function dynamically, and using the menu took another 10 seconds to > load. > > Oh, right. Don't be too concerned about compression. This is all just development-only. Other huge projects load in around 2-3 seconds once we build the core files. > After getting a list of all the swingjs files that it dynamically loads > (681) I concatenated them into one big swingjs.js file (4.9M minimized). I > couldn't load this in a script tag, I had to wait until I initialized the > applet. The easiest way to time it correctly was to replace > swingjs/j2s/javax/swing/Japplet.js with this file. Using this bundle hack > it only took 2.1 seconds to load the applet and the menus are ready to go > when you right click. (it also loads the molecular orbital packages). > That's not actually how it is done. Let me do one for you so you can see how it works. You can see the result here: > https://beta.chemcompute.org/site/__JmolApplet_applet.html > > I did the same with JSmol (only 40 files) and replaced > j2s/core/corejmol.z.js with a 2.3 M file. It loads in about half the time > (3 seconds instead of 6) and preloads a couple of functions I use. > > Are there any downsides to preloading everything like this? I tried > looking in the swingjs code and couldn't figure out where it could be > automated (I haven't looked in the JSmol transpiler at all). > > *Bob* |