|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
TOP THREE LINKS YOU MUST CLICK ON Feature AJAXWorld RIA Conference - Speaker Mike Girouard's JavaScript Design Patterns, #2
Load Time Configuration - also known as load time branching
By: Michael Girouard
Aug. 24, 2008 02:45 PM
Mike Girouard's Blog Load time configuration is also known as load time branching. MotivationThe primary motivation behind load time configuration is to optimize conditional operations such as generating XMLHttpRequest instances or adding event listeners. Since both operations vary amongst clients, specific conditions must be checked before proceeding. The load time configuration pattern runs once at load time and sets the resulting value so that it doesn’t need to be checked again. ImplementationThe most common technique for implementing load time configuration is by way of a Self-invoking function which returns the correctly configured value. The example below demonstrates how load time configuration can be used to normalize getting an XMLHttpRequest object. var getXHR = (function () { First, a getXHR variable is declared and it’s value is being assigned by the self-invoking function that follows. Upon execution, a conditional is run which determines the correct method of obtaining an XMLHttpRequest object. When a match is found, a wrapper function is returned and stored as the value for getXHR variable. ConclusionThe load time conditional pattern is used to configure a conditional value at load time. The result is a fully optimized value, specific to the the environment in which it is to be used. LATEST AJAXWORLD RIA STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||