# Build a Banking App Part 1: HTML Templates and Routes in a Web App When Apollo 11's guidance computer navigated to the moon in 1969, it had to switch between different programs without restarting the entire system. Modern web applications work similarly – they change what you see without reloading everything from scratch. This creates the smooth, responsive experience users expect today. Unlike traditional websites that reload entire pages for every interaction, modern web apps update only the parts that need changing. This approach, much like how mission control switches between different displays while maintaining constant communication, creates that fluid experience we've come to expect. Here's what makes the difference so dramatic: | Traditional Multi-Page Apps | Modern Single-Page Apps | |----------------------------|-------------------------| | **Navigation** | Full page reload for each screen | Instant content switching | | **Performance** | Slower due to complete HTML downloads | Faster with partial updates | | **User Experience** | Jarring page flashes | Smooth, app-like transitions | | **Data Sharing** | Difficult between pages | Easy state management | | **Development** | Multiple HTML files to maintain | Single HTML with dynamic templates | **Understanding the evolution:** - **Traditional apps** require server requests for every navigation action - **Modern SPAs** load once and update content dynamically using JavaScript - **User expectations** now favor instant, seamless interactions - **Performance benefits** include reduced bandwidth and faster responses In this lesson, we'll build a banking app with multiple screens that flow together seamlessly. Like how scientists use modular instruments that can be reconfigured for different experiments, we'll use HTML templates as reusable components that can be displayed as needed. You'll work with HTML templates (reusable blueprints for different screens), JavaScript routing (the system that switches between screens), and the browser's history API (which keeps the back button working as expected). These are the same fundamental techniques used by frameworks like React, Vue, and Angular. By the end, you'll have a working banking app that demonstrates professional single-page application principles. ## Pre-Lecture Quiz [Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/41) ### What You'll Need We'll need a local web server to test our banking app – don't worry, it's easier than it sounds! If you don't already have one set up, just install [Node.js](https://nodejs.org) and run `npx lite-server` from your project folder. This handy command spins up a local server and automatically opens your app in the browser. ### Preparation On your computer, create a folder named `bank` with a file named `index.html` inside it. We'll start from this HTML [boilerplate](https://en.wikipedia.org/wiki/Boilerplate_code): ```html Bank App ``` **Here's what this boilerplate provides:** - **Establishes** the HTML5 document structure with proper DOCTYPE declaration - **Configures** character encoding as UTF-8 for international text support - **Enables** responsive design with the viewport meta tag for mobile compatibility - **Sets** a descriptive title that appears in the browser tab - **Creates** a clean body section where we'll build our application > πŸ“ **Project Structure Preview** > > **By the end of this lesson, your project will contain:** > ``` > bank/ > β”œβ”€β”€ index.html > β”œβ”€β”€ app.js > └── style.css > ``` > > **File responsibilities:** > - **index.html**: Contains all templates and provides the app structure > - **app.js**: Handles routing, navigation, and template management > - **Templates**: Define the UI for login, dashboard, and other screens --- ## HTML Templates Templates solve a fundamental problem in web development. When Gutenberg invented movable type printing in the 1440s, he realized that instead of carving entire pages, he could create reusable letter blocks and arrange them as needed. HTML templates work on the same principle – instead of creating separate HTML files for each screen, you define reusable structures that can be displayed when needed. Think of templates as blueprints for different parts of your app. Just as an architect creates one blueprint and uses it multiple times rather than redrawing identical rooms, we create templates once and instantiate them as needed. The browser keeps these templates hidden until JavaScript activates them. If you want to create multiple screens for a web page, one solution would be to create one HTML file for every screen you want to display. However, this solution comes with some inconvenience: - You have to reload the entire HTML when switching screen, which can be slow. - It's difficult to share data between the different screens. Another approach is to have only one HTML file, and define multiple [HTML templates](https://developer.mozilla.org/docs/Web/HTML/Element/template) using the `