JavaScript Documentation

Overview

The main.js file provides essential interactive functionality for the website with a focus on accessibility, performance, and user experience.

Features

1. Mobile Menu Toggle

What it does:

Accessibility:

2. Smooth Scrolling

What it does:

Example:

<a href="#section-2">Jump to Section 2</a>

What it does:

4. Back to Top Button

What it does:

Styling:

5. Lazy Loading Fallback

What it does:

6. Print Optimization

What it does:

7. Accessibility Enhancements

What it does:

8. Console Easter Egg

What it does:

File Size

Browser Support

Testing

Desktop:

  1. Smooth scrolling with anchor links
  2. External link security attributes
  3. Back to top button appears after scrolling

Mobile (<768px):

  1. Hamburger menu toggle works
  2. Menu closes when clicking nav links
  3. Body scroll prevented when menu open
  4. Menu closes with Escape key

Accessibility:

  1. Navigate with keyboard (Tab, Enter, Escape)
  2. Screen reader announces menu state
  3. Reduced motion respected

Customization

Disable Back to Top Button

Remove lines 95-119 in main.js

Change Smooth Scroll Duration

Smooth scrolling uses browser defaults. To customize, add:

html {
  scroll-behavior: smooth;
}

Adjust Mobile Menu Breakpoint

Currently 768px. To change, update:

Dependencies