# External Libraries

> Dependency policy for the MrJuaumBR ecosystem and future web projects, including optional reusable UI inspirations.

## 1. Default policy

Use the smallest dependable toolset that solves the problem. The approved baseline for ordinary web projects is:

1. **Bootstrap 5** for responsive layout primitives and selected UI utilities;

1. **Font Awesome** for interface and brand icons;

1. **jQuery** for DOM/event/AJAX convenience where it materially improves delivery or where an existing project already depends on it.

These three libraries are allowed by default, but they are not a reason to use every available feature. Do not add another library merely because it is popular, familiar, or convenient for a small function that can be implemented with HTML, CSS, or a short, maintainable utility.

The current portfolio does not yet load Bootstrap or jQuery in its active homepage. Its historical `database/oldDatabase.html` uses Bootstrap 5.3.0, jQuery 3.5.1, and Font Awesome through a kit, while the active homepage uses Font Awesome 6.4.2 from cdnjs, Google Fonts, and Plyr. Treat the active homepage as the visual reference and the old database page as evidence of existing dependency compatibility—not as a requirement to duplicate its dependency list.

## 2. Approved baseline

### 2.1 Bootstrap 5

Use Bootstrap 5 when the project needs:

- a proven responsive grid or container system;

- standardized spacing, display, flex, sizing, or position utilities;

- accessible modal, collapse, dropdown, offcanvas, tooltip, or carousel behavior;

- consistent form and button baseline styling;

- rapid construction of a page with many conventional layouts.

Prefer Bootstrap’s CSS utilities and grid over custom breakpoint code when they express the design clearly. Use the project’s theme tokens to override Bootstrap variables or component properties. Do not let Bootstrap’s default colors silently replace the project’s skin/palette system.

Recommended loading order:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<link rel="stylesheet" href="/data/css/style.css">
```

Load Bootstrap before project CSS so the project owns the final visual language. Pin an explicit major/minor version; do not use an unversioned `latest` URL.

Bootstrap JavaScript is optional. Load `bootstrap.bundle.min.js` only when using Bootstrap’s JavaScript components. The bundle includes Popper and should be preferred over loading Popper separately.

```html
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
```

Do not load Bootstrap JavaScript merely to obtain the grid or utility classes. If the project uses custom dropdowns, tabs, or carousels already implemented in its own code, avoid creating two competing controllers for the same element.

### 2.2 Font Awesome

Use Font Awesome for:

- navigation and action icons;

- social and platform brand icons;

- status, direction, media, and utility icons;

- consistent icon treatment across related projects.

The current portfolio uses classes such as `fas`, `fab`, and custom icon classes for platforms not available in the standard set. Preserve the project’s icon vocabulary, but verify that every custom class actually has a definition or an appropriate fallback.

Prefer one loading method per project:

- a pinned CDN stylesheet for a static site;

- a Font Awesome kit when the project already uses a managed kit;

- self-hosted subsets when performance, privacy, or offline support matters.

Do not mix the CDN stylesheet, kit, and downloaded webfont in the same page. Avoid loading all icon families if the page uses only a small subset. If the project is bundled, tree-shake or subset icons where the build system supports it.

Icon rules:

- Mark decorative icons with `aria-hidden="true"`.

- Provide a visible label or `aria-label` for icon-only buttons.

- Do not use an icon as the only indication of a destructive or important action.

- Keep icons aligned through a shared utility class and semantic color tokens.

- Do not hard-code icon colors that break in another skin or palette.

- Keep enough space between an icon and its label for touch use.

Example:

```html
<button type="button" class="btn btn-primary" aria-label="Open theme settings">
  <i class="fa-solid fa-palette" aria-hidden="true"></i>
  <span>Theme</span>
</button>
```

### 2.3 jQuery

Use jQuery only when at least one of these conditions is true:

- the project already has meaningful jQuery code;

- a required plugin has a stable jQuery integration;

- a repetitive DOM/event/AJAX operation becomes substantially clearer and safer with jQuery;

- the project must maintain compatibility with an existing jQuery-based page.

Do not write new jQuery and native DOM code for the same component without a clear boundary. Pick one controller per feature. For a new small static page, native modern JavaScript is acceptable and may be preferable; the baseline permission does not make jQuery mandatory.

Load jQuery before any script that calls `$` or `jQuery`, and pin the version. Avoid multiple copies:

```html
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
        integrity="sha256-/JqT3SQfawRcv/BIHPThkB0Yw2iR8jVfV4zJ5J5h9s="
        crossorigin="anonymous"></script>
```

Use `defer` consistently for non-blocking scripts, but remember that dynamically injected scripts and scripts that depend on execution order need deliberate sequencing. Do not use `async` for a dependency chain.

If jQuery is used, keep selectors scoped and event delegation intentional:

```
$(document).on('click', '[data-action="open-theme"]', function () {
  // One delegated controller for dynamically rendered controls.
});
```

Do not use jQuery to compensate for unclear HTML structure. Keep semantic markup and data attributes stable so the feature can be migrated later.

## 3. Conditional libraries

Add a library only when the feature requires it and the native platform or approved baseline is insufficient. Document the reason beside the dependency and in the project’s dependency inventory.

### 3.1 Plyr

Plyr is justified for the portfolio’s embedded YouTube and HTML5 videos because it provides a consistent player UI and responsive controls. The current homepage loads Plyr CSS in the head, Plyr JavaScript before `main.js`, and initializes players after the relevant project content is available.

Rules:

- Load Plyr only on pages containing media that needs its controls.

- Pin the version and load the CSS before component styles.

- Destroy an existing player before reinitializing it when tabs or dynamic panels are changed.

- Keep native HTML5 controls as a fallback when the library fails.

- Do not initialize hidden players unnecessarily if the page contains many tabs.

- Provide a descriptive heading, captions/transcripts where applicable, and keyboard access.

- Respect reduced motion and avoid autoplay with sound.

### 3.2 Fonts

The current portfolio uses Inter and Press Start 2P from Google Fonts. Fonts are an optional visual dependency, not a functional dependency. Always provide a local/system fallback and use `font-display: swap` where self-hosting.

Do not add a new font for every skin. A skin may select from the ecosystem’s approved type scale, but typography must remain legible on phones, TVs, and low-resolution displays. Avoid using a pixel/display font for long paragraphs, tables, inputs, or controls.

### 3.3 Other UI libraries

Do not add another UI framework alongside Bootstrap for the same page-level responsibility. In particular, do not combine Bootstrap, Tailwind, Material UI, and a second component framework merely to obtain a few controls. Conflicting resets, breakpoints, z-index values, and theme variables make the ecosystem inconsistent.

React Bits is an optional source of component ideas and implementation references, not an approved reason to add React or a second design system to a project. Do not assume a linked demo is a drop-in, dependency-free component. Before adopting code, inspect its current package requirements, license, accessibility, maintenance, and compatibility with the project's framework; then adapt the markup and styles to the active skin and semantic tokens. Prefer a focused component over importing a broad library. If the project is not React-based, translate the interaction pattern to the existing stack instead of introducing React solely for decoration.

A specialized library may be added for a real need such as:

- charting with complex interaction;

- code syntax highlighting;

- 3D rendering;

- rich text editing;

- date/time or internationalization data beyond the platform APIs;

- virtualization for genuinely large lists;

- advanced media playback or editing.

Before adding one, record: the problem, why HTML/CSS/native JavaScript is insufficient, expected bundle cost, accessibility status, license, maintenance activity, loading strategy, fallback, and removal plan.

### 3.4 Preferred component references

Use these links as inspiration for reusable patterns. They are optional and should be adapted to the individual site's skin, palette, framework, and accessibility contract.

**Transitions.dev interaction patterns:**

- [Skeleton Loader and Reveal](https://transitions.dev/detail.html?t=skeleton-loader-and-reveal) — content-shaped loading placeholders and arrival transitions.
- [Tooltip Open and Close](https://transitions.dev/detail.html?t=tooltip-open-close) — themed, predictable tooltip visibility.
- [Magnetic Slider](https://transitions.dev/detail.html?t=magnetic-slider) — clearer slider targets and snapping feedback.
- [Menu Dropdown](https://transitions.dev/detail.html?t=menu-dropdown) — opening, closing, and selection states for menus.
- [Page Side by Side](https://transitions.dev/detail.html?t=page-side-by-side) — paired/split layouts that use space effectively and adapt to narrow screens.

**React Bits visual and control references:**

- [Neon Logo](https://reactbits.dev/animations/neon-logo) — cyber-tech logo treatment; reserve for suitable branding and keep a readable static fallback.
- [Gradient ASCII](https://reactbits.dev/backgrounds/gradient-ascii) — optional header or background texture; keep content contrast and performance in budget.
- [Halftone Reveal](https://reactbits.dev/animations/halftone-reveal) — image entrance/reveal; reserve media space and support reduced motion.
- [Branched Menu](https://reactbits.dev/micro/branched-menu) — hierarchical/nested menu presentation with accessible expansion.
- [Comet Dial](https://reactbits.dev/micro/comet-dial) — alternate slider/dial appearance while preserving range semantics.
- [Glide Select](https://reactbits.dev/micro/glide-select) — enhanced select appearance; preserve native form and keyboard behavior.
- [Spring Check](https://reactbits.dev/micro/spring-check) — animated checkbox inspiration for tasks and to-do lists.
- [Shape Waves](https://reactbits.dev/backgrounds/shape-waves) — optional layered wave background, themed through active tokens.

These examples do not become mandatory dependencies. Build or adapt them only when they solve a real interaction or visual need. Honor reduced motion, keyboard and touch operation, semantic HTML, skin-specific palettes, and a non-animated fallback.

## 4. CDN, security, and reliability

For every remote dependency:

- pin an exact version;

- use HTTPS;

- use Subresource Integrity where the provider publishes a stable hash;

- add `crossorigin="anonymous"` when required by SRI;

- avoid runtime dependency on an untrusted or unknown host;

- consider self-hosting for critical functionality;

- define what the page does if the CDN is unavailable;

- avoid injecting remote HTML or executing remote data as code.

Keep third-party origins intentional. The current site references cdnjs, jsDelivr-compatible assets, Google Fonts, Plyr, GitHub, GitHub API, Raw GitHub assets, Placehold.co, and Icons8 in legacy stylesheets. A future project should consolidate or remove unnecessary origins, especially legacy `styling.css` references that fetch icons through CSS `content: url(...)`.

Do not put API tokens or private credentials in client-side code. Treat GitHub API rate limits, third-party image failures, and remote video failures as normal runtime conditions. Show a themed empty/error state rather than allowing broken layout.

## 5. Loading and performance standard

Keep the critical rendering path small:

1. metadata and viewport;

1. critical theme boot state if needed to avoid a flash;

1. required CSS in dependency order;

1. project CSS;

1. deferred JavaScript in dependency order;

1. conditional feature initialization.

Use `loading="lazy"` for below-the-fold images and videos, but not for the primary hero asset when it is needed for first paint. Give images explicit dimensions or an aspect ratio to prevent layout shift. Do not load every project video, carousel image, or third-party widget before the user opens that feature.

Use Bootstrap’s responsive utilities and CSS grid/flex intentionally; do not ship a second layout abstraction for the same page. Keep custom CSS for the ecosystem’s identity, components, and skins.

## 6. Dependency inventory template

Every future project should maintain a small inventory, either in its main README or a project-specific dependency document:

| Dependency | Version | Purpose | Loaded where | Required? | Fallback | Removal trigger |
| --- | --- | --- | --- | --- | --- | --- |
| Bootstrap | 5.3.x | Grid/utilities and selected components | all pages / selected pages | baseline | project CSS for critical layout | no longer needed for layout |
| Font Awesome | 6.x | icons and brands | all icon pages | baseline | text labels / system fallback | icon subset is self-hosted |
| jQuery | 3.7.x | legacy/plugin DOM and events | only pages that use it | conditional baseline | native controller or static markup | no meaningful jQuery feature remains |
| Plyr | 3.7.x | video controls | media pages | conditional | native video controls | native controls meet requirements |

Update the inventory whenever a dependency is added, removed, upgraded, or moved to a different loading boundary.

## 7. Verification checklist

Before shipping a page:

- Confirm only the intended versions are loaded and no dependency is duplicated.

- Confirm the page still has a readable structure if a non-critical library fails.

- Confirm Bootstrap does not overwrite the theme/palette tokens.

- Confirm Font Awesome icons have labels or `aria-hidden` as appropriate.

- Confirm jQuery plugins are initialized after jQuery and destroyed when needed.

- Confirm no library creates page-wide horizontal overflow at phone widths.

- Confirm keyboard navigation, touch interaction, focus indication, and reduced motion.

- Confirm remote assets have sensible fallbacks and no secrets are exposed.

- Confirm the network panel shows no unnecessary third-party requests.

- Confirm the visual result is consistent with the individual site's skin and palette; do not force every ecosystem site to use the same skin catalog.

- Confirm optional React Bits-inspired controls remain accessible, themed, and usable if their animation or dependency fails.