Overview
Taskflow is built with vanilla JavaScript - no frameworks or libraries required. The application uses direct DOM manipulation and native browser APIs to provide a lightweight, fast task management experience.Key Characteristics
- Zero dependencies: Pure JavaScript with no React, Vue, or other framework overhead
- Direct DOM manipulation: Uses native
document.getElementById(),querySelector(), andcreateElement() - Event-driven architecture: All interactions handled through addEventListener
- localStorage persistence: Client-side data storage with JSON serialization
- TailwindCSS for styling: Utility-first CSS framework (dev dependency only)
File Structure
The application consists of three main files:Core Functions
All application logic is contained inapp.js. Here are the key functions:
guardarEnStorage() - Persist tasks to localStorage
guardarEnStorage() - Persist tasks to localStorage
Saves the entire tasks array to localStorage as a JSON string.Called after every task modification (add, delete, complete).
actualizarContadores() - Update section headers with task counts
actualizarContadores() - Update section headers with task counts
Updates the count display in each priority section header.Iterates through each priority level and counts visible tasks using
querySelectorAll('.tarea').length.crearTareaElemento(t) - Create task DOM element
crearTareaElemento(t) - Create task DOM element
Generates a complete task element with all interactive behaviors.This function:
- Creates a
<div>element with thetareaclass - Sets data attributes for filtering
- Builds inner HTML with task details
- Attaches click handlers for completion toggle and deletion
- Returns the fully configured element
aplicarTema(oscuro) - Apply dark/light theme
aplicarTema(oscuro) - Apply dark/light theme
Toggles dark mode using Tailwind’s
dark: class strategy.- Adds/removes the
darkclass on<html> - Updates button icon
- Persists theme preference to localStorage
cargarTareas() - Initialize app with saved/default tasks
cargarTareas() - Initialize app with saved/default tasks
Loads tasks from localStorage or seeds default data on first run.Called once on page load to populate the UI.
Task Data Structure
Each task is a JavaScript object with the following properties:Event Handling Approach
DOM Element References
All interactive elements are captured once on page load:Event Listeners
The application uses standardaddEventListener for all interactions:
Initialization Flow
- DOM Content Loaded: The script runs when HTML parsing completes
- DOM References: Capture all interactive elements
- Theme Applied: Load saved theme preference (
aplicarTema()) - Tasks Loaded: Retrieve from localStorage or use defaults (
cargarTareas()) - UI Rendered: Each task element created and appended to appropriate section
- Counters Updated: Section headers show correct task counts
- Event Listeners: All interactions are now active
The entire initialization happens synchronously - no async/await or promises needed since localStorage access is synchronous.
Performance Considerations
- Minimal DOM queries: Elements referenced once and reused
- Efficient filtering: Uses CSS
displayproperty instead of removing/re-adding elements - No virtual DOM: Direct manipulation is fast for this application size
- localStorage limits: Browser storage typically capped at 5-10MB