|
From: Robert H. <ha...@st...> - 2020-12-10 04:27:23
|
Mark, I checked in build-core.xml. If you run that, it will condense 623 files into site/swingjs/j2s/core/core_jmol.z.js (6.6 MB/1.5 MB transferred by server-side GZip). Then run build-site.xml, and __JmolApplet_applet_core.html will be transferred into /site/ from /site-resources. The only difference between these two is the line for Info.core: * core: "_jmol",* This loaded for me from https://chemapps.stolaf.edu/jmol/swingjs/site/__JmolApplet_applet_core.html in 1.4 sec (Firefox)/1.6 sec (Chrome) with the cache disabled, or 0.73/0.36 cached. I think this is about as good as we can expect. [image: image.png] On Wed, Dec 9, 2020 at 9:27 PM Robert Hanson <ha...@st...> wrote: > > > 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* > -- Robert M. Hanson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 *We stand on the homelands of the Wahpekute Band of the Dakota Nation. We honor with gratitude the people who have stewarded the land throughout the generations and their ongoing contributions to this region. We acknowledge the ongoing injustices that we have committed against the Dakota Nation, and we wish to interrupt this legacy, beginning with acts of healing and honest storytelling about this place.* |