AssetLoader Awesomeness FTW!!!!!!

15 views
Skip to first unread message

SamGoody

unread,
Jan 21, 2011, 5:35:29 AM1/21/11
to MooRTE
Those who have been following the code lately have probably noticed a
lot of effort put into a page called AssetLoader.js.

MooRTE was designed to be easily extensible, and has supported on
plugins since day one.
For example, the image upload function would use Digiterald's
FancyUpload.
These plug-ins are only included as needed [lazy loading].

Which is great, but requires setup for deferred loading. Not simple.
Over the past two years we have switched course several times on how
to do this.
At the beginning we had a small utility function, which was often
fiddled with.

When Mootools sanctioned Depender we spent quite some time reworking
and bloating our code to match.
We also spent a few weeks submitting bug reports and fixes to
Depender.
All for naught, as Depeneder went the way of the Dodo.

While recoding a "better" method, we made the following decision:
MooTools has a script called "Assets.js" in -More.
This script has an understandable syntax and is known to the Moo
Community already.
It would be perfect if just it had a few more things.

Like the ability to include more than on file at a time. The ability
to load scripts consecutively (as all browsers bork if a second files
is included and relies on a first file that hasn't completed loading).
The ability to run a script only if this is the first time it is being
included. Or each time. The ability to included multiple events.
Multiple file types, and all sorts of other stuff.
(We also have a bunch of bugs for Assets.js, but haven't got the time
to file. Burnt by my last experience.)

The result is the AssetLoader class.

It's got the same syntax as the Asset class, but adds all that other
stuff we needed.
In fact, add the line var Asset = AssetLoader and it will do all the
lifting you may have previously used Asset for.
And being coded from scratch, it even has it's own bugs!! ;)

So if any of you out there are looking for a lazy loading class,
consider using AssetLoader
If you have been looking for any given feature, give a shout.
(For example, you can have one image load by itself, followed by other
simultaneously, as we needed for an image gallery.)

Of course, bug reports are appreciated. Use GitHub issues, or post on
this thread.

Check things out:
https://github.com/siteroller/AssetLoader
http://mootools.net/docs/more/Utilities/Assets

Reply all
Reply to author
Forward
0 new messages