Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureHi Jacob,
I’m glad you enjoyed the presentation. I’m afraid there’s no easy answers to your questions, because every system is different based on the requirements that you have. In my world, yes, each module controls a specific part of the page. Within that module, you may have one or more widgets such as tabs. I can’t really give you a general "this is the way it should be" without understanding the context of the application, but I can say that you need to define the granularity both for "module" and for "widget", define that relationship, and use that to guide your design decisions.
You can pass data to a modules in any number of ways. You may, for instance, output configuration data onto the page that is tied to your module only by a unique ID that the framework can pick up. You also might embed the data inside of the module itself, or have the module request its data from the server once instantiated. It really depends on the overall system architecture. As I said when I gave the talk, I purposely didn’t include a lot of code because it really depends very heavily on your use case.
I don’t know jQuery very well, but your approach seems logical to me.19 hours ago
Nicholas Zakas
commented on
Scalable JavaScript Application Architecture@lorewap3 - I don’t know of any books that talk about this specifically (maybe I should write one!), but really, all of the concepts I talk about are in the realm of design patterns. If you pick up some good design pattern books, you’ll get a good base of understanding to start building a more scalable architecture.1 week ago
Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureI’m not sure I completely understand your question, but let me give this a shot. There’s really no concept of security in this architecture, you’re assuming that all modules were written by the application developer and, therefore, don’t need to be protected from one another. For communication and determining whether a module should be allowed to do something or not, that’s up to each extension. You should probably have some meta data associated with each module that the extension can look at to determine what it should or shouldn’t be able to do. But again, the responsibility for checking such meta data falls on the extensions themselves. For instance, the Ajax extension can determine whether or not to allow an Ajax request to go through.1 month ago
Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureThe idea is that you request the wrapper through the sandbox. For example:
var domUtil = sandbox.getService("domUtil");
The module still has to request access to the DOM utility, which provides the proper level of abstraction.1 month ago
Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureHi arnabc -
The best way to do this is to create a wrapper for the base library DOM methods you want to use and allow the modules to access that. That way, you can change the base library and just create a new wrapper with the same methods.1 month ago
Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureI’m sorry, I don’t have an example implementation to share. This was really just an architectural overview rather than a step-by-step implementation guide.2 months ago
Nicholas Zakas
commented on
Scalable JavaScript Application ArchitectureFu - No, this is correct. You only want to wrap the functions in a try-catch if you’re not in debug mode. In debug mode, this should be avoided so you can see the errors.2 months ago
Nicholas Zakas
commented on
Speed Up Your JavaScriptYou’re welcome. I’ve actually been trying to figure out if there’s a way to automatically detect stuff like this, but it would get a level of the JS engine that is way out of my realm of knowledge. :)6 months ago
Nicholas Zakas
commented on
Speed Up Your JavaScriptWhat we’re talking about here is really orders of magnitude. My tests involved using a single variable for a single operation. Images statements that are using multiple variables at the same time in a large web application with millions of lines of code. If you do anything a small enough number of times, the performance impact gets minimized. It’s when you multiply it out that you start to see issues.
Another interesting note is that times have only gotten reasonable recently. I had to remove IE6 and FF2 from the graph because it distorted the rest of the data. This shows that browsers are going in the right direction, we’re just not quite there yet.6 months ago
Comments