






Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!







The Largest Platform: The Web is a software platform, running on billions of devices like phones, computers, TVs, and watches. No Installation Needed: To use it, you don't need to install any special software; you just type a URL (web address) into a browser. Open Standards: It is built on open rules ( open standards ) that anyone can read, learn, and use to contribute. Internet vs. Web (The big di@erence): o The Internet: it is the physical infrastructure - the massive network of connected computers (as road network). o The Web: it is just one of many services that run on top of the Internet (Web = car using those roads) Other services on the Internet: Email (SMTP), file transfers (FTP), and video calls. Definition : The Web is a system of interconnected documents and applications accessed via a browser It is built on three open standards : One language for each part (websites are built on them):
CSS stands for Cascading Style Sheets. Separation of Concerns: This means HTML and CSS have completely diferent jobs.
...
.What is the Front-End?
The Language of the Web : JavaScript is the primary programming language used to make web pages interactive and dynamic. Runs in the Browser : It executes directly inside the user's web browser, so the user does not need to install anything. Real-Time Actions : It changes page content in real time, responds to user actions (like clicks), and talks to servers across the network. Server-Side Use : It can also run on a computer server using a tool called Node.js. History : It was created in 1995 by Brendan Eich in just 10 days. Type Coercion (A Common JS Trait) : JS tries to be helpful by automatically changing data types behind the scenes. For example, adding an empty array and an empty object [] + {} returns the string "[object Object]". How to Add JS to a Web Page
Preventing Form Reloads (event.preventDefault()) : By default, web browsers try to reload the entire screen when a is submitted. You must run event.preventDefault() inside your submit listener to block this behavior so your JavaScript code can handle the submission smoothly.
5. The Node.js Ecosystem and Packages - Packages : A package is a pre-written library or code module created by another developer that you can download and reuse to avoid rewriting common features from scratch. - Node.js : A special runtime environment that allows JavaScript code to execute outside of a web browser (like running directly on your laptop or on a cloud server). - npm (Node Package Manager) : The default software package manager installed with Node.js. It serves as the single largest online registry of JavaScript packages globally. Common npm Terminal Commands - npm init: Creates a brand-new project directory and generates a package.json configurations file. - npm install: Installs every dependency library listed inside an existing package.json file. - npm install axios: Downloads and installs a specific external library (like axios ) to your current project. - npm run dev: Runs a specific developer execution script configured inside your project's package.json. 6. Asynchronous JavaScript & fetch() Why Asynchronous (Async) Code is Mandatory JavaScript is single-threaded , meaning it is physically limited to doing only one task at a time. Requesting data from a distant web server takes time. If JavaScript ran synchronously, it would completely freeze up the webpage while waiting for the server to reply. Async patterns allow JavaScript to trigger a network task, keep running other code, and handle the server result later when it arrives. What is a Promise? A Promise is a JavaScript object that acts as a placeholder for data that will become available in the future. A Promise always sits in one of three states: 1. Pending : Still waiting for the network task to finish. 2. Fulfilled : The task completed successfully. 3. Rejected : The task failed or threw an error. The Modern Way: async / await While you can handle Promises using long chains of .then() and .catch(), modern developers prefer writing async / awaitbecause it reads top-to-bottom like standard code. - You can only use the await keyword inside a function marked with the async keyword. - You use standard try { ... } catch (error) { ... } blocks to capture structural failures. Using fetch() to Make API Calls fetch() is the native browser function used to make HTTP network requests. It returns a Promise. ⚠ The Exam Trap for fetch() : A fetch() request does not throw an error or trigger your catch block if the server returns a 404 Not Found or 500 Internal Error. It only throws a structural error if there is a literal network failure (like a disconnected internet line). Because of this, you must explicitly check if (!response.ok) to handle server errors safely. Code Example: fetch() GET Request with async/await JavaScript async function loadUserData () { try { const response = await fetch(" https://jsonplaceholder.typicode.com/users/1 "); // Check if the server response failed (status codes outside 200-299) if (!response.ok) { throw new Error (" Server error : " + response.status); }
// Extracting JSON from the response also returns a Promise! const user = await response.json(); console .log(user.name); } catch (error) { console .error(" Failed to load user data :", error); } }
A Modern Framework: Astro is a modern web framework designed specifically for building content-focused websites, such as blogs, portfolios, marketing sites, and documentation pages. The Core Philosophy: Its main goal is to ship as little JavaScript to the browser as possible. The Opposite Approach: Most standard frontend frameworks send massive JavaScript application bundles to the browser to build pages on the client side. Astro does the opposite: it generates static HTML on the server at build time, so the user's browser loads vanilla HTML instantly. Quick Facts: o Languages: JavaScript and TypeScript. o Current Version: Astro 6 (released March 10, 2026). o Installation Terminal Command: npm create astro@latest.
2. UI Frameworks vs. Meta-Frameworks Why do we need UI Frameworks? Standard JavaScript works fine, but as a web app grows larger, updating the DOM manually element-by-element becomes complicated and prone to bugs. UI frameworks fix this by providing structured components, automatic DOM changes, and predictable state trackers. The three dominant UI libraries mentioned are: 1. React (by Meta, 2013): Built as a tree of components using an HTML-like JavaScript syntax called JSX. It has a massive ecosystem but a steep learning curve. 2. Vue (by Evan You, 2014): Approachable, component-based, and uses Single-File Components. 3. Svelte (by Rich Harris, 2016): Fundamentally diferent because it has no virtual DOM. It compiles components directly down to plain, vanilla JavaScript at build time for excellent performance. What is a Meta-Framework? UI libraries (like basic React or Vue) only handle the component layer—they don't manage page routing, server optimizations, or build processes on their own. A meta-framework sits on top of a UI library to add those missing pieces so you can build complete, production-ready web apps. - React ➡ Next.js - Vue ➡ Nuxt - Svelte ➡ SvelteKit The Issue: These meta-frameworks make pages "heavy" with JavaScript, even for simple websites. Astro solves this by letting you use components from React, Vue, or Svelte inside an ultra-light Astro site. 3. Astro Project Structure When you generate a new Astro project, it follows a clean folder outline: - public/: Stores completely static assets like raw images, web fonts, icons, or text files that require zero automated code processing. - src/components/: Holds all your reusable pieces of user interface that are shared across pages. - src/layouts/: Special template shells used to wrap pages with matching scafolding (like shared metadata or universal sidebars). - src/pages/: The core directory for routing. Every individual file placed here automatically becomes a live URL path on your website with no manual configuration needed. For example, src/pages/about.astro automatically maps to the /about URL.
Value Requires a Server? User- Specific? Static Never / rarely ✅ Yes ❌ No server needed ❌ No Client-side Fetch At runtime (live) ❌ No ❌ No server needed ✅ Yes Server-Side Rendering (SSR) At runtime (live) ✅ Yes ✅ Yes, a server is required ✅ Yes Practical Project Management Commands When building or testing a real project, you interact using these four core console commands: