lab.js provides almost ready-to-run downloadable script for its Builder, but it needs some tweaks. Mostly it needs absolute paths replaced with relative paths in several files (included reassigning one obscure variable). It also must run from a server for the ServiceWorkerContainer. Close to working now, still no Preview mode, and exported files do not run. #labjs
Added a bunch of script to trace execution of each object in lab.js source code. #labjs
Understanding the inner workings of lab.js requires following multiple layers of indirection & inheritance. Perhaps typical for any large #OOP project. #JavaScript #labjs
Breakthrough! Turns out I was going about this the wrong way. The "source code" that I had was just precursors to generate the full source code, which then got minified. I managed to find full unminified source, so now I can start my exploration in earnest. #labjs
Exploring inner workings of lab.js by running it from readable source code. Learned so far:
- Must use 'type="module"' to load .js files that use "import".
- JavaScript modules will run only from a server, not from local drive.
- Relative references must start with either "/", "./", or "../".
- lab.js relies on several 3rd-party libraries (e.g., #lodash, #filesaver) which
developers must get for themselves.
#labjs
@mattewanlaws Thanks for the offer. I have a pretty specific objective: To understand the #JavaScript that underlies the lab.js framework. At my recommendation, we use #LabJs for conducting psychology research online (alternatives include #jsPsych and #PsychoJS). But I do not like using black boxes. We have the full source code for lab.js, and I want to understand it. But the flow of asynchronous code baffles me, nothing like the synchronous code I have handled for 45 years.
#javascript #labjs #jspsych #PsychoJS
Revised my lab.js session-counting demo to use "await fetch" when calling the PHP script from JavaScript. This requires setting some components to Tardy mode, a bit untidy but good enough. Now on to revising the PHP script.
#LabJS