With a very busy summer of client work behind us, the core CreateJS team is back in the saddle and working hard to get the next build of the libraries completed.
If you follow us on GitHub, you’ll have noticed that our Issues & Pull Requests are now up to date, and that we’ve been committing code constantly. We’re also working on a new site & community strategy, but that’s a topic for another post.
One of the low-level items we’ve tackled recently is revising our class and inheritance model. We wanted to standardize our approach, and make it a little more approachable, while keeping a strong focus on performance.
We implemented three major changes:
- Moved all property definitions off of the prototype and into the constructor. This produces a more consistent object signature, and allows browsers to more effectively optimize methods at run time. The end result: a display list that is over 2x faster, and vastly faster property access throughout the library. (Thanks to webskin & MannyC for the input)
- Added and implemented an
extendmethod. This codifies prototype inheritance in the library, and hopefully makes it easier for us to tweak the model moving forward.
- Added a
promotemethod, which promotes overridden superclass methods (and the constructor) to the subclass prototype. This makes these methods available in the object scope, without the significant performance overhead of using
The other effect of this change was eliminating the
initializemethods in favour of using promoted
As always, we were careful to make sure that these new methods are totally independent of the library (you can use them wherever), and also that we retained as much backwards compatibility as possible. You can still use the previous inheritance approach to extend classes in the library with no problems.
All of these changes have been made in a branch of each library, and will be merged to master in the next few days once they’ve had a bit more testing. If you’d like to check them out, or test with them, you can grab them here:
EaselJS, SoundJS, PreloadJS, TweenJS.
If you’d like to learn more about the changes, the EaselJS branch has an updated inheritance tutorial.
We’ve done a reasonable amount of testing, but with the number of deep changes we’ve made in the past few weeks, we’d really appreciate if you could take a few moments to test your existing content against these revisions. The main thing you are likely to run into, is the missing
initialize methods, if you’ve been extending classes. Also, be sure to check out the VERSIONS file for each library for a full list of changes.