A production-grade, framework-free component loader system built with TypeScript, SCSS, and static HTML for GitHub Pages deployment.
- Zero FOUC (Flash of Unstyled Content) - Smooth loading with opacity transitions
- Component-Based Architecture - Reusable header, footer, and navigation components
- Hash Router - SPA-like navigation without page reloads
- Smart Prefetching - Hover-based and viewport-based prefetching
- Loading Indicators - Visual progress bar for component loading
- Active Nav States - Automatic highlighting of current page
- Route Guards - Protect routes with custom validation
- TypeScript-First - Full type safety and auto-completion
- Dark Mode Support - Built-in theme toggle with localStorage persistence
- Smooth Transitions - Page and component load animations
- GitHub Pages Ready - Automated deployment with GitHub Actions
mastorsCDN/
├── index.html # Main entry point
├── about.html # About page
├── contact.html # Contact page
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Actions deployment
├── src/
│ ├── ts/
│ │ ├── main.ts # App initialization
│ │ ├── router.ts # Hash router with transitions
│ │ ├── component-loader.ts # Component loading system
│ │ └── prefetch.ts # Smart prefetching logic
│ └── scss/
│ ├── main.scss # Main stylesheet
│ ├── _variables.scss # Design tokens
│ ├── _components.scss # Component styles
│ └── _transitions.scss # Animations
├── components/
│ ├── header.html # Header component
│ ├── footer.html # Footer component
│ └── nav.html # Navigation component
└── dist/
├── css/
│ └── mastorscdn.css # Compiled CSS (auto-generated)
└── js/
└── main.js # Compiled JS (auto-generated)
# Clone the repository
git clone https://github.com/KEHEM-IT/mastorsCDN.git
cd mastorsCDN
# Install dependencies
npm install
# Build the project
npm run build# Start development with watch mode
npm run dev
# Watch TypeScript only
npm run watch:ts
# Watch SCSS only
npm run watch:scss
# Build for production
npm run buildPush to main branch:
git add .
git commit -m "Your message"
git push origin mainThe GitHub Action will automatically build and deploy to GitHub Pages.
npm run build
npm run deploy- Create HTML file in
components/directory - Add component slot in HTML:
<div id="my-component-slot"></div>- Load component in
src/ts/main.ts:
await this.loader.loadComponents([
{ selector: '#my-component-slot', path: 'components/my-component.html' }
]);In src/ts/main.ts, register routes:
this.router.register('page-name', {
path: 'page-name',
title: 'Page Title',
guard: () => {
// Optional: return false to prevent navigation
return true;
}
});Add styles to src/scss/_components.scss:
.my-component {
padding: var(--spacing-lg);
background: var(--bg-elevated);
}The project includes a built-in dark/light theme system. Customize colors in src/scss/_variables.scss:
:root {
--bg-primary: #ffffff;
--text-primary: #1a1a1a;
--accent-primary: #6366f1;
}
[data-theme="dark"] {
--bg-primary: #0a0a0a;
--text-primary: #ffffff;
}- Component Caching - Components loaded once and cached
- Smart Prefetching - Prefetch on hover with delay
- Viewport Prefetching - Prefetch visible links on idle
- Progressive Loading - Show progress during component load
- Optimized Transitions - Hardware-accelerated CSS transitions
Protect routes with custom logic:
this.router.register('admin', {
path: 'admin',
title: 'Admin Panel',
guard: () => {
const isAuthenticated = checkAuth();
if (!isAuthenticated) {
alert('Please login first');
return false;
}
return true;
}
});- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with TypeScript, SCSS, and modern web standards
- Inspired by modern SPA frameworks but keeping it simple
- Part of the MastorsCDN ecosystem
- 📧 Email: contact@kehem.com
- 💬 GitHub Issues: Report a bug
- 📚 Documentation: View Docs
Made with ❤️ by KEHEM-IT