Many javascript libraries like MooTools, Dojo, ExtJS, YUI, and Qooxdoo have their source code organized in a structure that developers can use as a basis for organizing their own code. MooTools, YUI, and ExtJS have an online means of selecting the pieces of code needed and downloading a single script with all the selected code and required dependencies. This is great for optimizing the target library, but your code left not optimized: existing in separate files, uncompressed, and a polluter of the global namespace (if you care). This article describes one means for solving these issues.
Read the rest of this entry »
Tags: Javascript, Optimize, Organize
2 Comments »
There’s been quite a bit of talk about polluting the global namespace. It is certainly one of those things I try to be conscious of when I develop. I wanted a convenient means of creating namespaces and importing classes into them. This led to the development of Package.
Package provides a method for dynamically creating namespaces. These namespaces can be immediately used to create classes, simple functions, variables, etc. Existing classes that are organized in folder structures can be imported at any time using a namespace that resembles the path to the class.
Other javascript and css files can also be included on a page using the static include method.
Using the require and include methods make it possible to create web pages that load much faster by delaying the load of classes until you need them in your code. There are also two events (success and failure) that can be observed so that code can executed accordingly.
Check out the project page for usage information and examples.
Tags: Class, Javascript, Prototype
No Comments »