From 7d5fd4589c6ddac69ef9580bc9472481e97dac9e Mon Sep 17 00:00:00 2001 From: Patrick McElhaney Date: Wed, 21 Dec 2011 09:19:23 -0500 Subject: [PATCH] Started writing script. --- index.html | 6 +- script.md | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 script.md diff --git a/index.html b/index.html index e860a70..830f834 100755 --- a/index.html +++ b/index.html @@ -171,6 +171,8 @@

Immediately Invoked Function Expression

+ + @@ -180,8 +182,8 @@

Immediately Invoked Function Expression

Problems

diff --git a/script.md b/script.md new file mode 100644 index 0000000..6dafd51 --- /dev/null +++ b/script.md @@ -0,0 +1,207 @@ +#AMD Be Lazy, Not Sloppy + +## What 5 things do I wan to cover? +1. Why we need AMD (why IIFEs and namespaces are bad). +2. How AMD works +3. Concatenating +4. Implementations & Adoption +5. Plugins (CSS, text, etc.) + + +## Three problems we need to solve in 2012. + +There are three problems that we as JavaScript need to solve in 2012. + +- The first is **global pollution** [Al Gore]. That's the easy one. JavaScript + has a global object -- the window object, in the case of browsers -- and by + default, that's where variables go. It's shared by all of the scripts on a + page, so we want to avoid polluting it. We don't want to put variables in + the global namespace because we can't be sure we're not clobbering variables + from another script. + + Unfortunately, we have to use some global variables so that scripts can + communicate with one another. + +- The next problem is **our scripts are too big** [mega block]. A script + should have a single purpose, it should be reusable every time we need to do + the one specific thing that script is designed to do. It allows us to *snap + pieces of code together like legos*, using *design patterns* such as + *strategy*. As stated in the *single responsibility principle*, a script + should have *one reason to change*. That means a script should be so tiny + it defines a *single function* or a single configuration object. + + Unfortunately, lots of tiny scripts are bad for the browser, because it + can only download up to eight scripts in parallel. We'll come back to + that. + + [Slide of a long list of `