Trust me, it’s technical, but it will all make sense soon.
We want our code to be easy for the browser to download and use.
So, how do we write code that’s easy for both developers to work with, and for the browser to use?
We do have a way to achieve the goal of simple code that’s fast for the browser. First, we write code that’s meaningful, and that we can understand. Then, we run that code through a compiler, which breaks it down into the absolutely smallest form it can be. So, something like “passenger” might become just “a.” This may not seem like a big deal, but applying changes like that hundreds and thousands of times over the course of a large project offers massive benefits. It compacts our meaningful code so that the browser can very quickly download and use it.
It’s a lot like lunch.
This is where tools like require.js and Almond come in handy. They make it really easy for us to break up the code into smaller, independent chunks that have their own refrigerator, so they can’t steal each others’ lunches. Using these tools allows us to put a “wrapper” (a sandwich bag, if you will) around our code so that it can talk back and forth with others’ code when it needs to, but it’s protected from being moved around or otherwise messed with.
So it is possible to meet all three points of the iron triangle if you use the right tools. Using a compiler, we can create easy-to-read code, and thanks to tools like require.js and Almond, our code is safe for other developers to edit and use. And we can even use third-party scripts to save time and money. Ultimately, all of these tools help the browser to speedily chomp through the code and serve up the page.
Still not making sense? Let's get lunch and chat about it.