-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Milestone
Description
Let's take a day and make all of Javascript require-able using require.js.
There are several parts to this:
- Go through very javascript module and make it adhere to the AMD standard.
- Modify the
javascript()andjavascriptMod()methods to add the requested javascript module to a list. - Modify
Layoutclass to use the list from calls tojavascript()andjavascriptMod()to generate the config file (per page) that require.js needs.
Pros:
- Quickly gets us out of javascript dependency/ordering problems.
- Allows us to start participating in the AMD standard, which looks to be the state of the art
Cons:
- Doesn't minify/compile javascript as much as absolutely possible. Each JS that is loaded via require will still trigger a separate HTTP request, which is sub-optimal. However, those files will be able to be consistently cached (since they won't vary by page) on the client browser. The impact will be greatest on first page load, but should be minimal after that.
Bonus
Move all inclusion of JS to the bottom of the page, just before the closing </body> tag (for page performance). But.. This will break any in-line js included in body.js files, or directly in page templates, so it needs to be done carefully and with great testing.
┆Issue is synchronized with this Asana task