From the course: JavaScript: Best Practices for Data

Using modern deployment tools - JavaScript Tutorial

From the course: JavaScript: Best Practices for Data

Start my 1-month free trial

Using modern deployment tools

- [Instructor] In the early days of JavaScript, the code a developer wrote was the code that was executed in every browser or other user agent. Over time, JavaScript evolved and added new features. However, because not every user was using the newest version of a browser, developers had to write code targeted at the lowest common denominator. That is, the browser with the fewest modern features that still maintained a critical mass of users. This meant that developers were constrained from using the newest features or had to write and maintain multiple versions of the same code. The modern JavaScript workflow has resolved this issue using transpilers. A transpiler is a utility that accepts JavaScript code written using modern features, and returns code that does the same job as the original but is written without modern features. Babel is an example of a popular transpiler for JavaScript. Including a transpiler in your deployment process means that you can take advantage of modern and even cutting edge JavaScript features without worrying that your code won't perform as expected for users of older browsers. Not every modern JavaScript feature can be transpiled however. But for those that can't, developers use another tool, the polyfill. A polyfill is a library that you include with your code at deployment. Because a transpiler can't rebuild some code for older browsers, the job of a polyfill is to instead add the functionality of the new feature to older browsers. Promises and Fetch are a widely used example or a feature that requires a polyfill for backward compatibility. With transpiling and polyfills in the developer toolbox for JavaScript developers, the group that maintains JavaScript standards has been free to innovate without worrying about proposed changes never being widely available. As a result, many new features of JavaScript serve to help developers write cleaner, more manageable code, rather than to add new capabilities to the language. It's due to the widespread use of Babel and polyfills, that many modern JavaScript best practices involve use of these developer focused features.

Contents