Last updated June 29, 2012.
In Drupal 8 we are going to make JavaScript rock! We want JavaScript we can all be proud of. Currently we have an 8-part plan to get there.
Clean Up The Current Code
There is room to improve our current JS:
- #1481560: Add "use strict" to all core JavaScript to enforce clean code
- #1415788: [Meta] javascript spring clean-up
- #1574470: [Meta] selectors clean-up
- #1419652: [Meta] javascript logging and error reporting
- #1440628: [Meta] the big javascript toolbar/tableheader/overlay/fragment mess
Unit Testing
JS Unit testing via QUnit, even possibly something like jQuery Swarm.
Better Inline Documentation
Drupal is one of the best documented open source projects. Time to bring our JS up to the level of everything else.
Pluggable Preprocessing
Sometimes we write modules like Bundle Cache or we want to load scripts via scripts like labjs. Making preprocessing/aggregation pluggable means we can do some awesome stuff there.
- #352951: Make JS & CSS Preprocessing Pluggable
- #1014086: Consider using imagecache style generation of css and javascript aggregates
Drupal JS Handbook Awesomeness
"JavaScript is the only language that I'm aware of that people feel they don't need to learn before they start using it." -- Douglas Crockford
Let's teach people how to do our common stuff.
JSLint/JSHint
JSLint and JSHint are great for helping us keep our JS from doing bad things. Let's use one of them in both our personal dev processes and coder module.
#1664940: [Policy, patch] Decide on JSHint configuration
Minification
Let's minify our JS. The size savings can translate into real end user performance.
Solid Architectural Patterns For All The JS
There is a LOT of JS in Drupal 7 and we imagine even more in Drupal 8. Architecturally we can benefit from using modular patterns, like what Dojo or jQuery UI are using. In addition there are some libraries, like underscore, that may be able to provide utilities that help us write better JS.
- #1542344: Use AMD for JS architecture
- #1541860: Reduce dependency on jQuery
- #1446166: Use JS events instead of Drupal.behaviors
- #1090592: [meta] Use HTML5 data-* attributes instead of #ID selectors in Drupal.settings
- #1033392: Script loader support in core (LABjs etc.)
- #1172670: Evaluate standardized usage of HTML5 Storage API (e.g. through a library)
The actual issues involved in all of this can be found in the issue queue at http://drupal.org/project/issues/3060/term/232