LABjs 2.0 beta now officially ready for testing

170 views
Skip to first unread message

Kyle Simpson

unread,
May 24, 2011, 12:06:27 AM5/24/11
to LABjs Announce
LABjs 2.0, a *long* time in the making, is a complete ground-up rewrite
(with API backwards compatibility, except for a few removed configs). It is
now officially in beta, and ready for wide-spread testing. Please use the
issue tracker on github for any bugs/issues.

https://github.com/getify/LABjs/tree/master/next


New/awesome in 2.0:
* `AllowDuplicates` now actually works across chains! Huge win, yay! This is
very important for those who want to use multiple/nested $LAB chains as part
of a shared-dependency loading mechanism. (In fact, mLABjs -- module
LABjs -- is in the works for just that sort of thing).

* Chains are now fully resumable, meaning you can save the return value from
the last call to a chained function, and then use that saved value later as
the starting point to resume the chain from where it left off.

* Queueing is now built-in, with `queueScript`, `queueWait` and
`runQueue` -- this important for those who want to build up the chain across
multiple files or inline <script> elements (like in the CMS case), but want
to defer starting the loading of the code starting until later (usually at
the bottom of the page).

* LABjs now supports `noConflict` (for rolling back to a previous
version/copy of $LAB on the page) and `sandbox` (for creating a new pristine
sandboxed copy of the current $LAB)

* LABjs now relies on feature-testing for `async=false` and
implicit/explicit "true preloading" (currently only IE, but in the spec
process). Ugly/hacky "cache preloading" is now only used for "older webkit"
(before March 2011 nightlies, Chrome 12, etc), and even then, only for
remote files.

* For XHR preloading (only used in "older webkit" for local files, by
default), to support better debugability, "// @sourceURL=..." is appended to
the code, to map the XHR injected code to a real file name. Currently,
browsers only support this for eval() (not script injection, like LABjs
uses). But, browsers will likely be adding this functionality to script
injection as well, in which case LABjs debugability of XHR'd scripts will
greatly improve automatically.

* Speaking of debugging, LABjs now supports a DEBUG mode (only if you use
the source file, or if you use the LABjs-debug.min.js production file) *and*
enable the "Debug" config option, which captures all the inner workings (and
any errors in .wait() calls) to the browser's console.log, if present.

* LABjs now supports a "CacheBust" config option, which will attempt to make
sure all loaded scripts are forcibly loaded new on each page refresh, by
auto-appending a random number parameter to each URL.
****This is really only practical/advised for DEV environments, where you
want to ensure that the code reloads every time. Doing so in production
would be really bad for user performance.*****

* As part of LABjs' rewrite, the code style is now significantly improved in
readability (most "minification" hacks have been removed), and it's also
using more memory-savvy code, such as far fewer closures. As a result, LABjs
should run leaner and faster, if only by a little bit. The goal is to get
LABjs out of the way so your scripts load and run as fast as possible.

* NOTE: "AppendTo", "UsePreloading", and "UseCachePreloading" options were
removed as they are no longer useful. This is the only
backwards-incompatible change (no actual API changes, just config), and the
change should just cause older usage code to continue to operate as normal
while ignoring the no longer supported options. Still, test your code
carefully if you've been using either of those 3 config options before.

* For all that new awesomeness, LABjs minified and gzip'd (without DEBUG
code) is *ONLY 16 BYTES LARGER*!! Without gzip, the difference is much more
drastic (revealing just how much more readable/bigger the source code is),
at an increase of 998 bytes! Thank goodness for the miracles of gzip!


-----------------------

Phew! That's a lot of stuff! What are you waiting for, go download and start
using/testing the new and greatly improved LABjs 2.0!

https://github.com/getify/LABjs/tree/master/next

--Kyle


Reply all
Reply to author
Forward
0 new messages