mindtangle

JSLoad

Screenshot of header and copyright for the JSLoad fileI almost forgot about this, which is strange because I wrote it all the way back in August, 2007 and use it on a daily basis. JSLoad is a clever bit of plumbing that powers all of the user interface over at Instructables. We’ve released it under an open-souce license (LGPL.) A lot of non-coder friends read my blog, so the coolness of it may not be apparent. Suffice it to say that I’m proud of it, despite its rough edges. I’m also hoping that it will be useful to others.

For the geeks, JSLoad is a script loader and dependency manager:

The real usefulness of JSLoad comes with its ability to group dependencies using tags. Tags are arbitrary labels that you can apply to (i.e. make dependent on) any group of files or other tags. Tags can be applied to single files or multiple files. Multiple tags can be applied to a single file. You can even think of your tags as depending upon a portion of a file (say, class within a file containing several classes.)

As a result, you can mimic most other dependency structures: Chains, trees, or more complicated graphs. You can tag things that often appear together, that share a certain aspect; whatever your usage calls for. At Instructables, for example, we generally have a base set of widgets and features whose dependencies are primarily tree-like. Those little bits are then collected into larger groupings like “editable” or “commentable”; abstract labels that approximate the kinds of interfaces that are common on our site.

Tags are also very useful while refactoring code. Often, because of the flexibility of Javascript, you won’t be sure of the best way to split your code across files. Which portions will be used together most often, and should thus be grouped together to reduce HTTP requests? With JSLoad, you can tag the variant groupings, then organize your code as you wish. Your web pages will just call JSLoad the tags as they need them. Over time, you may find that one tag is used much more often than the others. Using JSLoad, you can refactor your code into a more efficient file structure, without changing any of the script calls in the pages that use the code.

Click through to the official page to read more or to download the code for yourself. You can also preview it on the test page to see it in action.

Related Posts:

Post-Plugin Library missing

Leave a Reply

Comments can use Markdown syntax. The toolbar at the top will mark up your text using Markdown, automatically. If you'd like to use XHTML, these tags are available: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Live Comment Preview

alternative to diazepam buy levitra on line Metformin buying tramadol without a prescription tenuate order canadian rx ed pharmacy herbal oxazepam reviews generic cialis free sample prescription for lorazepam buy viagra now cheapest generic valium buying klipal online buy xanax online best herbal zyban