beautyjoy / llab

Lightweight lab curriculum system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2017 Loader Re-Write

cycomachead opened this issue · comments

Lunch Time thoughts..

  • Replace SetTimeout w/ an onload for each script, that calls the section loaded function, and the load next section function if everything is good
  • Add a hook for scripts that can be conditionally loaded, based on a CSS selector or function.

More difficult stuff:

  • define script dependencies and linearize a DAG
  • allow all scripts to be loaded, but don't execute them until dependencies are loaded (requires adapting each script to not execute code immediately.

That last part is mostly done.

Perhaps we can define a module syntax?

llab.modules = {
   curriculum: {
      dependencies: ['jQuery', 'library'],
      path: 'src/curriculum.js',
      onLoad: function() {},
      ...,
  },
};

This feels like reinventing the wheel. Maybe a build system is still just easier. :/

Then we can have a meta onLoad function that checks if dependencies are ready and if so calls the onLoad for that module. Then if the dependencies aren't ready, it can create callbacks.