|Title||Front End Technology Standards|
|Author||Andy Armstrong <email@example.com>|
|Arbiter||Matt Drayer <firstname.lastname@example.org>|
This document describes the technology standards for developing front end applications and components for Open edX. It covers the techniques and approaches that are currently recommended, as well as the technologies and libraries that should be used.
The rapid pace of development in front end tooling has created opportunities to greatly improve the quality of the Open edX user and developer experience. After an assesment of industry best practices, the edX Front End Working Group (FedX) has made a number of technology recommendations for libraries, frameworks and tooling to modernize the edX front end.
Server-side content should be rendered with Django Templates
Rationale: There are many template languages available for Django, but the simplest option is to use the built-in Django template engine. The Open edX codebase has a mixture of Django and Mako templates, but the former are easier to reason about because they don’t support arbitrary code evaluation. See Reasons for rejecting Mako for a more detailed explanation.
Exception: Mako templates can continue to be used within edx-platform for consistency with the existing code base. This is because the base templates and theming support are all provided via Mako, so it is too much to expect a new feature to be implemented with a different framework. There is much desire to replace Mako within edx-platform so this exception may eventually be removed.
Exception: Much of edX’s existing front end code is written conformant to the version of ECMA-262 released in 2009 (ES5). Files written in ES5 should be gradually converted to the newer standard as new development in those feature areas requires.
Note: edX previously used CoffeeScript, but its use has now been deprecated. Community interest in TypeScript has also grown, but it and other languages that do not follow the ECMA-262 spec should not be used. See Reasons for rejecting CoffeeScript and Reasons for rejecting TypeScript for more detail.
Use React and Redux when building new client-side applications
Rationale: React should be used for building new UIs, as it is widely adopted by the community and strikes a balance between flexibility and feature richness. For state management of complex client-side interactions, Redux should be used. This library was chosen because it sees strong use in the React community, but is also flexible enough to be used in situations where a hybrid React/Backbone architecture exists.
See React at edX for more details on the evaluation process that led to this technology selection. Other modern frameworks considered for use included Polymer and Angular. See Reasons for rejecting Angular and Reasons for rejecting Polymer for an exploration of why these alternatives do not work as well as React for edX.
Rationale: Webpack is the tool of choice for code optimization and bundling, as it is widely used throughout the industry, and because it seamlessly handles modern code bases as well as all of the older technologies used by edX, such as AMD Modules. Webpack should be implemented to handle as much of the “asset pipeline” as possible, rather than passing this responsibility on to Django.
CSS should be generated using Sass
Rationale: Sass’s SCSS syntax is an extension of CSS that adds power and elegance to the basic language. It makes the maintenance of large CSS files more manageable though the ability to use variables, mixins, imports and more. In particular, it makes theming possible with the ability to override variables that define colors, fonts etc.
You can find out more about Sass in the official Sass documentation.
Polymer is a framework built around Web Components, a set of draft extensions to the HTML and DOM specs for UI encapsulation. Web Components are a very interesting area of emergent Web technology, but are not yet finalized as a spec or supported in many browsers. Because of this, the Polymer community is small and performance issues exist. As Web Components become more mature, edX may reevaluate their use, either with Polymer or without.
There are a number of reasons why Django templates is preferred to Mako: