# Frontend development ## Javascript Tausi uses [ES6 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). The file `tausi/js/app.js` is the top-level entrypoint, used to import all other scripts. Tausi uses [Webpack](https://webpack.js.org/) to import dependencies and compile the ES6 modules into a single javascript file. Javascript which must be compiled is stored in `tausi/js` since it doesn't need to be sent directly to the user. Javascript libraries sent to the user, such as jQuery and the compiled Tausi app, are stored in `tausi/static/js`. ### Code style Tausi uses ESLint to enforce the [Standard JS](https://github.com/standard/standard) code formatting style, with the modification to require semicolons. ### Helpers Tausi has some helper code that makes certain common functions simpler. #### data-confirm Forms, links and buttons that have a `data-confirm="message"` attribute will ask the user to confirm that the operation should continue when clicked or submitted. If the user says no, the action is cancelled. #### data-component When a page loads, Tausi looks for HTML elements that have a `data-component="MyComponent"` attribute. It searches for the corresponding ES6 class from the `tausi/js/components/` directory and, if present, creates it, passing the HTML element as the first parameter. This provides a simple mechanism for attaching certain Javascript behaviour to an HTML element. To create a new component called `FunComponent`: 1. create a new file `tausi/js/components/fun.js` and in it declare a class `export class FunComponent { ... }` 2. edit `tausi/js/components/index.js` to export the new class: `export { FunComponent } from './fun';` 3. use the component in HTML: `