|
|
re: Javascript, window.onload and namespacing
by Mike Roeder on Mar 31, 2008 - 02:27 PM read 221 times |
Hey Eric - as we discussed, I think our best bet is to use Prototype for the event loading (Event.observe(window, 'load')) and perhaps the Prototype extend or Class creation for namespacing. Our issues involve IE compatability (which I think you've solved with the prototype Class creation), where all this javascript lives, and, do we load this BSG name-spaced script on every page? Or do we manually load it where needed? How does sub name-spacing work? For example, I have a bunch of scripts related to wiki versioning (for example). But I don't want to load ALL of the other BSG scripts - is there a way to do this? It's likely that it doesn't matter, I'm just curious.
-
re: re: Javascript, window.onload and namespacing
a reply to re: Javascript, window.onload and namespacing
in a conversation thread started here
by Marc Schriftman on Apr 01, 2008 - 05:07 PM read 153 timesSo, I've found a slightly nicer wrapping around the Dean Edwards solution that was actually included in a few plugins floating around for Rails. I've attached a simple test set to see how it works. The idea is essentially to create a BsgClass that gets all our methods as we need it. New scripts can attache more methods or objects to the class and we'll trust our FastInit (the lib I mentioned above) to load up our instance. In theory we could probably then figure out an import/require scheme to help reduce loading too much, but honestly, we aren't at that point in in terms of size or anything so I'm not too worried.
javascript_namespaces.zip


