@wazir-dev/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
# Network Optimization
|
|
2
|
+
|
|
3
|
+
> Expertise module for web network performance engineering.
|
|
4
|
+
> Every claim includes concrete numbers. Sources are cited inline.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
1. [HTTP/2 vs HTTP/3 (QUIC)](#http2-vs-http3-quic)
|
|
11
|
+
2. [Resource Hints](#resource-hints)
|
|
12
|
+
3. [Fetch Priority API](#fetch-priority-api)
|
|
13
|
+
4. [Service Workers for Caching and Offline](#service-workers-for-caching-and-offline)
|
|
14
|
+
5. [Compression: Brotli vs Gzip](#compression-brotli-vs-gzip)
|
|
15
|
+
6. [Critical Request Chain Optimization](#critical-request-chain-optimization)
|
|
16
|
+
7. [Connection Management and Keep-Alive](#connection-management-and-keep-alive)
|
|
17
|
+
8. [Early Hints (103 Status Code)](#early-hints-103-status-code)
|
|
18
|
+
9. [Common Bottlenecks](#common-bottlenecks)
|
|
19
|
+
10. [Anti-Patterns](#anti-patterns)
|
|
20
|
+
11. [Before/After Waterfall Diagrams](#beforeafter-waterfall-diagrams)
|
|
21
|
+
12. [Decision Tree: Resource Prioritization](#decision-tree-resource-prioritization)
|
|
22
|
+
13. [Sources](#sources)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## HTTP/2 vs HTTP/3 (QUIC)
|
|
27
|
+
|
|
28
|
+
### Protocol Evolution
|
|
29
|
+
|
|
30
|
+
HTTP/2 introduced multiplexing over a single TCP connection, eliminating the need for
|
|
31
|
+
domain sharding and connection pooling hacks of the HTTP/1.1 era. HTTP/3 goes further
|
|
32
|
+
by replacing TCP entirely with QUIC, a UDP-based transport that solves head-of-line
|
|
33
|
+
blocking at the transport layer.
|
|
34
|
+
|
|
35
|
+
### Performance Benchmarks
|
|
36
|
+
|
|
37
|
+
| Metric | HTTP/2 | HTTP/3 (QUIC) | Improvement |
|
|
38
|
+
|----------------------------|--------------|----------------|--------------------|
|
|
39
|
+
| Time to First Byte (avg) | 201 ms | 176 ms | 12.4% faster |
|
|
40
|
+
| Page load (synthetic) | 1.5 s | 0.8 s | 47% faster |
|
|
41
|
+
| Prioritization gains | Baseline | Up to 50% | Critical resources |
|
|
42
|
+
| Connection migration | Not supported| Supported | Mobile benefit |
|
|
43
|
+
| Head-of-line blocking | Present (TCP)| Eliminated | Lossy networks |
|
|
44
|
+
|
|
45
|
+
Source: Akamai 2025 report; Cloudflare HTTP/3 benchmarks
|
|
46
|
+
(https://blog.cloudflare.com/http-3-vs-http-2/)
|
|
47
|
+
|
|
48
|
+
### When HTTP/3 Wins Big
|
|
49
|
+
|
|
50
|
+
1. **Mobile on unstable networks**: QUIC handles packet loss without stalling all
|
|
51
|
+
streams. On a 2% packet loss connection, HTTP/3 maintains throughput while HTTP/2
|
|
52
|
+
over TCP can see 30-50% degradation.
|
|
53
|
+
2. **Network transitions**: QUIC supports connection migration via connection IDs.
|
|
54
|
+
When a phone switches from Wi-Fi to cellular, the connection continues seamlessly
|
|
55
|
+
instead of requiring a full TCP + TLS handshake (1-3 RTTs saved).
|
|
56
|
+
3. **High-latency connections**: QUIC's 0-RTT resumption eliminates a full round trip
|
|
57
|
+
on repeat visits. HTTP/2 over TLS 1.3 achieves 1-RTT; QUIC achieves 0-RTT for
|
|
58
|
+
returning connections.
|
|
59
|
+
|
|
60
|
+
### When HTTP/2 Is Comparable
|
|
61
|
+
|
|
62
|
+
On stable, low-latency data center connections, HTTP/3 offers marginal gains over
|
|
63
|
+
well-tuned HTTP/2. TCP has decades of kernel-level optimization, and modern Linux
|
|
64
|
+
kernels handle it extremely efficiently. The difference can be under 5 ms in
|
|
65
|
+
controlled environments.
|
|
66
|
+
|
|
67
|
+
### Adoption Status (2025)
|
|
68
|
+
|
|
69
|
+
- Global HTTP/3 adoption: **35%** of web traffic (Cloudflare, October 2025)
|
|
70
|
+
- Browser support: Chrome, Firefox, Safari, Edge all support HTTP/3 by default
|
|
71
|
+
- CDN support: Cloudflare, Akamai, Fastly, AWS CloudFront all offer HTTP/3
|
|
72
|
+
- Server support: NGINX (via quiche), Caddy, LiteSpeed natively; Apache via mod_h3
|
|
73
|
+
|
|
74
|
+
### Implementation Checklist
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
[x] Enable HTTP/3 on your CDN or load balancer
|
|
78
|
+
[x] Add Alt-Svc header to advertise HTTP/3 support
|
|
79
|
+
[x] Verify QUIC is not blocked by firewalls (UDP port 443)
|
|
80
|
+
[x] Test with Chrome DevTools Protocol tab (hover over protocol column)
|
|
81
|
+
[x] Monitor with RUM to compare HTTP/2 vs HTTP/3 user cohorts
|
|
82
|
+
[x] Keep HTTP/2 as fallback -- never disable it
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Resource Hints
|
|
88
|
+
|
|
89
|
+
Resource hints allow developers to assist the browser in deciding which resources to
|
|
90
|
+
fetch, connect to, or prepare ahead of time. Used correctly, they shave 100-500 ms
|
|
91
|
+
off critical resource loading. Used incorrectly, they waste bandwidth and compete
|
|
92
|
+
with genuinely critical resources.
|
|
93
|
+
|
|
94
|
+
### dns-prefetch
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<link rel="dns-prefetch" href="https://cdn.example.com">
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- **What it does**: Resolves the DNS for a domain in the background.
|
|
101
|
+
- **Cost**: Minimal -- a single DNS lookup is typically 20-120 ms.
|
|
102
|
+
- **When to use**: Third-party domains you will need but are not immediately critical.
|
|
103
|
+
- **Browser support**: Universal, including IE11.
|
|
104
|
+
- **Overhead**: Negligible. Safe to apply to 4-6 third-party domains.
|
|
105
|
+
|
|
106
|
+
### preconnect
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- **What it does**: DNS + TCP + TLS handshake (full connection setup).
|
|
113
|
+
- **Cost**: More expensive than dns-prefetch. Each preconnect holds a socket open.
|
|
114
|
+
- **Time saved**: 100-300 ms per connection (DNS + TCP + TLS combined).
|
|
115
|
+
- **When to use**: Origins serving critical above-the-fold resources (font CDN,
|
|
116
|
+
primary API, image CDN).
|
|
117
|
+
- **Limit**: **2-4 origins maximum**. Preconnecting to many domains is
|
|
118
|
+
counterproductive -- it steals bandwidth and CPU from actual resource downloads.
|
|
119
|
+
|
|
120
|
+
**Pattern: Combine dns-prefetch with preconnect for resilience**
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<!-- Browsers that support preconnect use it; others fall back to dns-prefetch -->
|
|
124
|
+
<link rel="preconnect" href="https://cdn.example.com" crossorigin>
|
|
125
|
+
<link rel="dns-prefetch" href="https://cdn.example.com">
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### preload
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin>
|
|
132
|
+
<link rel="preload" href="/hero.webp" as="image">
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **What it does**: Mandatory fetch -- the browser MUST download this resource
|
|
136
|
+
immediately, regardless of whether it has been discovered in the HTML yet.
|
|
137
|
+
- **Key requirement**: The `as` attribute is **mandatory**. Without it, the browser
|
|
138
|
+
fetches the resource twice (once without proper priority, once when actually needed).
|
|
139
|
+
- **When to use**:
|
|
140
|
+
- Fonts referenced in CSS (browser cannot discover them until CSS is parsed)
|
|
141
|
+
- LCP images loaded via CSS background-image
|
|
142
|
+
- Critical scripts loaded by other scripts (import chains)
|
|
143
|
+
- **Impact**: Preloading an LCP image can improve LCP by 200-600 ms by eliminating
|
|
144
|
+
the discovery delay.
|
|
145
|
+
- **Danger**: Preloading too many resources degrades performance. Chrome issues a
|
|
146
|
+
console warning if a preloaded resource is unused within 3 seconds.
|
|
147
|
+
|
|
148
|
+
### prefetch
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<link rel="prefetch" href="/next-page-bundle.js" as="script">
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- **What it does**: Low-priority fetch for a resource needed on a **future** page.
|
|
155
|
+
- **When to use**: Resources for the next likely navigation (e.g., the second step of
|
|
156
|
+
a checkout flow). The browser downloads these at idle priority.
|
|
157
|
+
- **Impact**: Can reduce next-page load time by 200-1000 ms depending on resource size.
|
|
158
|
+
- **Caveat**: Purely speculative. If the user does not navigate to the expected page,
|
|
159
|
+
the bandwidth is wasted. Use analytics to confirm navigation patterns before
|
|
160
|
+
prefetching.
|
|
161
|
+
|
|
162
|
+
### modulepreload
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<link rel="modulepreload" href="/components/hero.js">
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- **What it does**: Fetches, parses, and compiles a JavaScript module, placing it in
|
|
169
|
+
the module map ready for execution. Unlike standard preload, which just caches the
|
|
170
|
+
raw bytes, modulepreload does the parse + compile work upfront.
|
|
171
|
+
- **When to use**: Critical ES module imports that are deep in the import chain.
|
|
172
|
+
Without modulepreload, the browser discovers module B only after parsing module A.
|
|
173
|
+
- **Browser support**: Chrome, Edge, Firefox (since v115, Sept 2023), Safari.
|
|
174
|
+
- **Limit**: Do not modulepreload more than 5-8 modules. Excessive modulepreload
|
|
175
|
+
links in the `<head>` delay First Contentful Paint by competing for main-thread
|
|
176
|
+
parse time (reported in Angular CLI issue #27490, 2024).
|
|
177
|
+
|
|
178
|
+
### Resource Hints Summary Table
|
|
179
|
+
|
|
180
|
+
| Hint | Action | Priority | Use Case | Limit |
|
|
181
|
+
|---------------|-------------------------|------------|----------------------------------|-----------|
|
|
182
|
+
| dns-prefetch | DNS lookup | Background | Third-party domains | 4-6 |
|
|
183
|
+
| preconnect | DNS + TCP + TLS | High | Critical third-party origins | 2-4 |
|
|
184
|
+
| preload | Full fetch (mandatory) | High | Late-discovered critical assets | 2-5 |
|
|
185
|
+
| prefetch | Full fetch (idle) | Low | Next-page resources | 2-4 |
|
|
186
|
+
| modulepreload | Fetch + parse + compile | High | Deep ES module dependencies | 5-8 |
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Fetch Priority API
|
|
191
|
+
|
|
192
|
+
The Fetch Priority API (`fetchpriority` attribute) gives developers explicit control
|
|
193
|
+
over how the browser prioritizes individual resource fetches within the same resource
|
|
194
|
+
type.
|
|
195
|
+
|
|
196
|
+
### Syntax
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<!-- Boost LCP image priority -->
|
|
200
|
+
<img src="/hero.webp" fetchpriority="high" alt="Hero image">
|
|
201
|
+
|
|
202
|
+
<!-- Deprioritize below-the-fold images -->
|
|
203
|
+
<img src="/footer-logo.png" fetchpriority="low" alt="Footer logo" loading="lazy">
|
|
204
|
+
|
|
205
|
+
<!-- Boost critical script -->
|
|
206
|
+
<script src="/critical-analytics.js" fetchpriority="high"></script>
|
|
207
|
+
|
|
208
|
+
<!-- Deprioritize non-critical script -->
|
|
209
|
+
<script src="/chat-widget.js" fetchpriority="low"></script>
|
|
210
|
+
|
|
211
|
+
<!-- Also works with fetch() -->
|
|
212
|
+
<script>
|
|
213
|
+
fetch('/api/critical-data', { priority: 'high' });
|
|
214
|
+
fetch('/api/recommendations', { priority: 'low' });
|
|
215
|
+
</script>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Measured Impact
|
|
219
|
+
|
|
220
|
+
| Scenario | Before | After | Improvement |
|
|
221
|
+
|---------------------------------------|------------|------------|-------------|
|
|
222
|
+
| Google Flights LCP image | 2.6 s | 1.9 s | 27% faster |
|
|
223
|
+
| Generic hero image (3G simulation) | 4.1 s | 3.2 s | 22% faster |
|
|
224
|
+
| Below-fold image deprioritization | LCP 3.0 s | LCP 2.4 s | 20% faster |
|
|
225
|
+
|
|
226
|
+
Source: web.dev Fetch Priority case study
|
|
227
|
+
(https://web.dev/articles/fetch-priority)
|
|
228
|
+
|
|
229
|
+
### Browser Support (2025)
|
|
230
|
+
|
|
231
|
+
- Chrome: Yes (since v101, April 2022)
|
|
232
|
+
- Safari: Yes (since v17.2, December 2023)
|
|
233
|
+
- Firefox: Yes (since v132, October 2024)
|
|
234
|
+
- Edge: Yes (follows Chromium)
|
|
235
|
+
|
|
236
|
+
### Best Practices
|
|
237
|
+
|
|
238
|
+
1. **Use `fetchpriority="high"` on exactly 1-2 resources per page** -- the LCP image
|
|
239
|
+
and potentially one critical above-the-fold script.
|
|
240
|
+
2. **Use `fetchpriority="low"` liberally** on below-the-fold images, non-critical
|
|
241
|
+
scripts, and speculative fetches.
|
|
242
|
+
3. **Combine with `loading="lazy"`** for images: `fetchpriority="low"` signals intent
|
|
243
|
+
during the fetch; `loading="lazy"` defers the fetch entirely until near-viewport.
|
|
244
|
+
4. **Do not set everything to high** -- if everything is high priority, nothing is.
|
|
245
|
+
Overuse causes bandwidth contention between resources that should be sequential.
|
|
246
|
+
|
|
247
|
+
### Anti-Pattern: Priority Inversion
|
|
248
|
+
|
|
249
|
+
```html
|
|
250
|
+
<!-- BAD: Three high-priority images compete for bandwidth -->
|
|
251
|
+
<img src="/hero.webp" fetchpriority="high">
|
|
252
|
+
<img src="/promo-1.webp" fetchpriority="high">
|
|
253
|
+
<img src="/promo-2.webp" fetchpriority="high">
|
|
254
|
+
|
|
255
|
+
<!-- GOOD: Only the LCP image is boosted -->
|
|
256
|
+
<img src="/hero.webp" fetchpriority="high">
|
|
257
|
+
<img src="/promo-1.webp">
|
|
258
|
+
<img src="/promo-2.webp" fetchpriority="low">
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Service Workers for Caching and Offline
|
|
264
|
+
|
|
265
|
+
Service workers act as a programmable network proxy between the browser and the
|
|
266
|
+
server. They enable aggressive caching strategies that dramatically improve repeat
|
|
267
|
+
visit performance and unlock offline functionality.
|
|
268
|
+
|
|
269
|
+
### Five Caching Strategies
|
|
270
|
+
|
|
271
|
+
#### 1. Cache First (Cache Falling Back to Network)
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
Request --> Cache hit? --> YES --> Return cached response
|
|
275
|
+
\--> NO --> Fetch from network --> Cache response --> Return
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
- **Best for**: Static assets (CSS, JS bundles, fonts, images) that change
|
|
279
|
+
infrequently.
|
|
280
|
+
- **Performance**: Near-instant responses (~1-5 ms) for cached assets.
|
|
281
|
+
- **Risk**: Stale content if cache is not versioned properly.
|
|
282
|
+
|
|
283
|
+
#### 2. Network First (Network Falling Back to Cache)
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
Request --> Fetch from network --> Success? --> YES --> Cache + Return
|
|
287
|
+
\--> NO --> Return cached response
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
- **Best for**: Dynamic content (API responses, user-specific data, news feeds).
|
|
291
|
+
- **Performance**: Always fresh when online; graceful offline fallback.
|
|
292
|
+
- **Risk**: Full network latency on every request when online.
|
|
293
|
+
|
|
294
|
+
#### 3. Stale While Revalidate
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
Request --> Return cached response immediately
|
|
298
|
+
\-> Fetch from network in background --> Update cache for next request
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
- **Best for**: Content that should be fresh but where stale is acceptable briefly
|
|
302
|
+
(product listings, dashboards, configuration).
|
|
303
|
+
- **Performance**: Cache-speed responses (~1-5 ms) with eventual freshness.
|
|
304
|
+
- **Tradeoff**: Users see stale data until the next navigation.
|
|
305
|
+
|
|
306
|
+
#### 4. Cache Only
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
Request --> Cache hit? --> YES --> Return
|
|
310
|
+
\--> NO --> Fail
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
- **Best for**: App shell resources that were precached during service worker install.
|
|
314
|
+
- **Performance**: Fastest possible -- no network involvement.
|
|
315
|
+
|
|
316
|
+
#### 5. Network Only
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
Request --> Fetch from network --> Return (no caching)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
- **Best for**: Non-cacheable requests (POST, real-time data, authentication).
|
|
323
|
+
- **Performance**: Standard network latency.
|
|
324
|
+
|
|
325
|
+
### Performance Impact Numbers
|
|
326
|
+
|
|
327
|
+
| Metric | Without SW | With SW (Cache First) | Improvement |
|
|
328
|
+
|-------------------------------|---------------|-----------------------|----------------|
|
|
329
|
+
| Repeat visit page load | 2.8 s | 0.9 s | 68% faster |
|
|
330
|
+
| Static asset response time | 150-400 ms | 1-5 ms | 97% faster |
|
|
331
|
+
| Offline availability | 0% | 100% (cached pages) | Full offline |
|
|
332
|
+
| Bandwidth on repeat visit | Full download | 0 bytes (cached) | 100% saved |
|
|
333
|
+
|
|
334
|
+
### Recommended Strategy by Resource Type
|
|
335
|
+
|
|
336
|
+
| Resource Type | Strategy | Cache Duration |
|
|
337
|
+
|--------------------|------------------------|--------------------|
|
|
338
|
+
| App shell HTML | Cache First | Until SW update |
|
|
339
|
+
| CSS / JS bundles | Cache First | Until hash changes |
|
|
340
|
+
| Fonts | Cache First | 1 year |
|
|
341
|
+
| API responses | Network First | 5-30 minutes |
|
|
342
|
+
| Product images | Stale While Revalidate | 24 hours |
|
|
343
|
+
| User avatar | Stale While Revalidate | 1 hour |
|
|
344
|
+
| Auth endpoints | Network Only | Never cache |
|
|
345
|
+
| Analytics pings | Network Only | Never cache |
|
|
346
|
+
|
|
347
|
+
### Cache Versioning
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
const CACHE_VERSION = 'v2';
|
|
351
|
+
const CACHE_NAME = `app-cache-${CACHE_VERSION}`;
|
|
352
|
+
|
|
353
|
+
self.addEventListener('activate', (event) => {
|
|
354
|
+
event.waitUntil(
|
|
355
|
+
caches.keys().then((names) =>
|
|
356
|
+
Promise.all(
|
|
357
|
+
names
|
|
358
|
+
.filter((name) => name !== CACHE_NAME)
|
|
359
|
+
.map((name) => caches.delete(name))
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
);
|
|
363
|
+
});
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Key Metric: Cache Hit Ratio
|
|
367
|
+
|
|
368
|
+
Track your service worker cache hit ratio. A well-configured service worker on a
|
|
369
|
+
content-heavy site should achieve **85-95% cache hit ratio** for static assets on
|
|
370
|
+
repeat visits. Below 70% indicates misconfigured cache rules or overly aggressive
|
|
371
|
+
expiration.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Compression: Brotli vs Gzip
|
|
376
|
+
|
|
377
|
+
### Compression Ratio Comparison
|
|
378
|
+
|
|
379
|
+
Brotli consistently outperforms gzip on text-based web assets. At its highest
|
|
380
|
+
compression level (11), Brotli produces files **15-25% smaller** than gzip at its
|
|
381
|
+
highest level (9).
|
|
382
|
+
|
|
383
|
+
| Content Type | Gzip (level 6) | Brotli (level 11) | Brotli Savings |
|
|
384
|
+
|--------------|-----------------|--------------------|--------------------|
|
|
385
|
+
| HTML | 78% reduction | 85% reduction | ~21% smaller |
|
|
386
|
+
| CSS | 80% reduction | 87% reduction | ~19% smaller |
|
|
387
|
+
| JavaScript | 77% reduction | 84% reduction | ~18% smaller |
|
|
388
|
+
| JSON API | 79% reduction | 85% reduction | ~17% smaller |
|
|
389
|
+
| SVG | 75% reduction | 82% reduction | ~16% smaller |
|
|
390
|
+
|
|
391
|
+
Source: Akamai benchmark, median savings of 82% (Brotli) vs 78% (gzip) across a
|
|
392
|
+
large sample. Paul Calvano analysis, March 2024
|
|
393
|
+
(https://paulcalvano.com/2024-03-19-choosing-between-gzip-brotli-and-zstandard-compression/)
|
|
394
|
+
|
|
395
|
+
### Speed vs Size Tradeoff
|
|
396
|
+
|
|
397
|
+
| Operation | Gzip (level 6) | Brotli (level 4) | Brotli (level 11) |
|
|
398
|
+
|---------------|-----------------|-------------------|--------------------|
|
|
399
|
+
| Compress | 45 MB/s | 40 MB/s | 2-5 MB/s |
|
|
400
|
+
| Decompress | 300 MB/s | 290 MB/s | 290 MB/s |
|
|
401
|
+
| Ratio | Good | Good (+5%) | Best (+15-25%) |
|
|
402
|
+
|
|
403
|
+
Key insight: **Brotli decompression is nearly identical in speed to gzip** regardless
|
|
404
|
+
of compression level. The cost is only at compression time. This means:
|
|
405
|
+
|
|
406
|
+
- **Static assets**: Pre-compress at Brotli level 11 during build. The one-time
|
|
407
|
+
compression cost is amortized over millions of requests.
|
|
408
|
+
- **Dynamic responses**: Use Brotli level 4-5 for on-the-fly compression. At level 4,
|
|
409
|
+
Brotli matches gzip's compression speed while still producing ~5% smaller output.
|
|
410
|
+
|
|
411
|
+
### Adoption (2024-2025)
|
|
412
|
+
|
|
413
|
+
Per HTTP Archive data (January 2024), Brotli is now used more than gzip for
|
|
414
|
+
JavaScript and CSS resources globally. Browser support is universal across modern
|
|
415
|
+
browsers (Chrome, Firefox, Safari, Edge).
|
|
416
|
+
|
|
417
|
+
### Implementation
|
|
418
|
+
|
|
419
|
+
```nginx
|
|
420
|
+
# NGINX configuration
|
|
421
|
+
brotli on;
|
|
422
|
+
brotli_comp_level 6; # Real-time compression level (balance speed/ratio)
|
|
423
|
+
brotli_types text/plain text/css application/javascript application/json
|
|
424
|
+
image/svg+xml application/xml;
|
|
425
|
+
|
|
426
|
+
# Serve pre-compressed .br files for static assets
|
|
427
|
+
brotli_static on;
|
|
428
|
+
|
|
429
|
+
# Keep gzip as fallback
|
|
430
|
+
gzip on;
|
|
431
|
+
gzip_comp_level 6;
|
|
432
|
+
gzip_types text/plain text/css application/javascript application/json
|
|
433
|
+
image/svg+xml application/xml;
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Build-Time Pre-Compression
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Pre-compress all static assets at maximum Brotli level
|
|
440
|
+
find dist/ -type f \( -name "*.js" -o -name "*.css" -o -name "*.html" -o -name "*.svg" \) \
|
|
441
|
+
-exec brotli --best {} \;
|
|
442
|
+
|
|
443
|
+
# Result: dist/main.js (245 KB) --> dist/main.js.br (48 KB)
|
|
444
|
+
# Compare: dist/main.js.gz (58 KB) -- Brotli is 17% smaller
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Zstandard: The Emerging Alternative
|
|
448
|
+
|
|
449
|
+
Zstandard (zstd) is gaining traction as a compression algorithm that offers gzip-like
|
|
450
|
+
speed with Brotli-like ratios. Chrome added zstd support in 2024. However, adoption
|
|
451
|
+
is still early -- use Brotli as the primary algorithm and monitor zstd browser support
|
|
452
|
+
for future consideration.
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## Critical Request Chain Optimization
|
|
457
|
+
|
|
458
|
+
A critical request chain is a series of dependent network requests that must complete
|
|
459
|
+
sequentially before the page can render. Each link in the chain adds latency equal to
|
|
460
|
+
at least one network round trip.
|
|
461
|
+
|
|
462
|
+
### Anatomy of a Critical Chain
|
|
463
|
+
|
|
464
|
+
```
|
|
465
|
+
HTML document (1 RTT)
|
|
466
|
+
--> blocking CSS (1 RTT)
|
|
467
|
+
--> @import in CSS (1 RTT)
|
|
468
|
+
--> font referenced in CSS (1 RTT)
|
|
469
|
+
--> background image in CSS (1 RTT)
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
**Total: 5 sequential round trips before LCP**. At 100 ms RTT, that is a minimum of
|
|
473
|
+
500 ms of pure network wait time, not counting download time.
|
|
474
|
+
|
|
475
|
+
### Chain-Breaking Strategies
|
|
476
|
+
|
|
477
|
+
#### 1. Inline Critical CSS (eliminates 1-2 RTTs)
|
|
478
|
+
|
|
479
|
+
```html
|
|
480
|
+
<head>
|
|
481
|
+
<style>
|
|
482
|
+
/* Critical above-the-fold CSS inlined -- ~14 KB max (fits in first TCP window) */
|
|
483
|
+
.hero { ... }
|
|
484
|
+
.nav { ... }
|
|
485
|
+
</style>
|
|
486
|
+
<link rel="preload" href="/full.css" as="style"
|
|
487
|
+
onload="this.onload=null;this.rel='stylesheet'">
|
|
488
|
+
</head>
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Impact: Eliminates the blocking CSS fetch. FCP improves by 100-300 ms.
|
|
492
|
+
|
|
493
|
+
#### 2. Eliminate @import Chains
|
|
494
|
+
|
|
495
|
+
```css
|
|
496
|
+
/* BAD: Creates a chain -- main.css uses @import for reset.css and typography.css */
|
|
497
|
+
```
|
|
498
|
+
```html
|
|
499
|
+
<!-- GOOD: Flatten into parallel HTML link tags -->
|
|
500
|
+
<link rel="stylesheet" href="/reset.css">
|
|
501
|
+
<link rel="stylesheet" href="/typography.css">
|
|
502
|
+
<link rel="stylesheet" href="/main.css">
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
All three CSS files now download in parallel instead of sequentially.
|
|
506
|
+
|
|
507
|
+
#### 3. Preload Late-Discovered Resources
|
|
508
|
+
|
|
509
|
+
```html
|
|
510
|
+
<!-- Font is only discovered after CSS is parsed -- add preload to start early -->
|
|
511
|
+
<link rel="preload" href="/fonts/inter-v13.woff2" as="font"
|
|
512
|
+
type="font/woff2" crossorigin>
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
Impact: Removes 1 RTT from the chain. Font loads in parallel with CSS instead of
|
|
516
|
+
after it. Typical improvement: 150-400 ms.
|
|
517
|
+
|
|
518
|
+
#### 4. Defer Non-Critical JavaScript
|
|
519
|
+
|
|
520
|
+
```html
|
|
521
|
+
<!-- BAD: Blocks rendering -->
|
|
522
|
+
<script src="/analytics.js"></script>
|
|
523
|
+
|
|
524
|
+
<!-- GOOD: Downloads in parallel, executes after parsing -->
|
|
525
|
+
<script src="/analytics.js" defer></script>
|
|
526
|
+
|
|
527
|
+
<!-- ALSO GOOD: Downloads in parallel, executes as soon as ready -->
|
|
528
|
+
<script src="/analytics.js" async></script>
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
| Attribute | Download | Execution | Use Case |
|
|
532
|
+
|-----------|----------------|-----------------------|-----------------------------|
|
|
533
|
+
| (none) | Blocking | Immediately | Must avoid |
|
|
534
|
+
| async | Non-blocking | ASAP (order varies) | Independent scripts |
|
|
535
|
+
| defer | Non-blocking | After HTML parsed | Scripts needing DOM |
|
|
536
|
+
| type=module| Non-blocking | Deferred by default | ES modules |
|
|
537
|
+
|
|
538
|
+
#### 5. Reduce Third-Party Chain Depth
|
|
539
|
+
|
|
540
|
+
Third-party tag managers are notorious chain creators. A tag manager script loads,
|
|
541
|
+
evaluates its container, then injects additional analytics, pixel, and tracking
|
|
542
|
+
scripts -- each adding another round trip to the chain.
|
|
543
|
+
|
|
544
|
+
**Mitigation**: Load tag managers with `async`, set `fetchpriority="low"`, and
|
|
545
|
+
audit tags quarterly. The median website loads **20 external scripts totaling 449 KB**
|
|
546
|
+
(HTTP Archive 2024 Web Almanac).
|
|
547
|
+
|
|
548
|
+
### Measuring Chain Depth
|
|
549
|
+
|
|
550
|
+
Use Lighthouse's "Avoid chaining critical requests" audit or Chrome DevTools
|
|
551
|
+
Performance panel. Target: **maximum chain depth of 2** for above-the-fold rendering.
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## Connection Management and Keep-Alive
|
|
556
|
+
|
|
557
|
+
### The Cost of New Connections
|
|
558
|
+
|
|
559
|
+
Each new TCP connection requires:
|
|
560
|
+
|
|
561
|
+
| Step | Time (100ms RTT) | Time (200ms RTT) |
|
|
562
|
+
|---------------|-------------------|-------------------|
|
|
563
|
+
| DNS lookup | 20-120 ms | 20-120 ms |
|
|
564
|
+
| TCP handshake | 100 ms (1 RTT) | 200 ms (1 RTT) |
|
|
565
|
+
| TLS handshake | 200 ms (2 RTTs) | 400 ms (2 RTTs) |
|
|
566
|
+
| **Total** | **320-420 ms** | **620-720 ms** |
|
|
567
|
+
|
|
568
|
+
### Keep-Alive Benefits
|
|
569
|
+
|
|
570
|
+
HTTP/1.1 keep-alive (persistent connections) reuses TCP connections across multiple
|
|
571
|
+
requests. Benchmarks show that reusing connections reduces total request time by a
|
|
572
|
+
factor of **3x** compared to opening new connections for each request, and up to **5x**
|
|
573
|
+
in multi-cloud environments.
|
|
574
|
+
|
|
575
|
+
```nginx
|
|
576
|
+
# NGINX keep-alive configuration
|
|
577
|
+
keepalive_timeout 65; # Keep connection open for 65 seconds
|
|
578
|
+
keepalive_requests 1000; # Allow 1000 requests per connection
|
|
579
|
+
|
|
580
|
+
# Upstream keep-alive (to backend servers)
|
|
581
|
+
upstream backend {
|
|
582
|
+
server 10.0.0.1:8080;
|
|
583
|
+
keepalive 32; # Pool of 32 persistent connections
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### HTTP/2 Connection Coalescing
|
|
588
|
+
|
|
589
|
+
HTTP/2 multiplexes all requests to the same origin over a **single connection**. This
|
|
590
|
+
eliminates the need for:
|
|
591
|
+
|
|
592
|
+
- Domain sharding (anti-pattern in HTTP/2)
|
|
593
|
+
- Sprite sheets (individual files are fine now)
|
|
594
|
+
- CSS/JS concatenation (bundling is still useful for other reasons)
|
|
595
|
+
|
|
596
|
+
**Important**: HTTP/2 allows up to **100 concurrent streams** per connection by default.
|
|
597
|
+
Most browsers use a single connection per origin.
|
|
598
|
+
|
|
599
|
+
### Connection Pool Sizing (Backend)
|
|
600
|
+
|
|
601
|
+
For server-to-server connections (API calls, database, microservices):
|
|
602
|
+
|
|
603
|
+
| Environment | Recommended Pool Size | Rationale |
|
|
604
|
+
|---------------|----------------------|-------------------------------------|
|
|
605
|
+
| Development | 10-20 | Low concurrency |
|
|
606
|
+
| Staging | 50-100 | Moderate load testing |
|
|
607
|
+
| Production | 100-200 | High concurrency, avoid exhaustion |
|
|
608
|
+
|
|
609
|
+
Source: Microsoft Developer Blog on HTTP connection pooling
|
|
610
|
+
(https://devblogs.microsoft.com/premier-developer/the-art-of-http-connection-pooling-how-to-optimize-your-connections-for-peak-performance/)
|
|
611
|
+
|
|
612
|
+
### Connection Limits Per Domain
|
|
613
|
+
|
|
614
|
+
Browsers enforce per-domain connection limits:
|
|
615
|
+
|
|
616
|
+
| Protocol | Max Connections/Domain | Implication |
|
|
617
|
+
|----------|------------------------|---------------------------------------|
|
|
618
|
+
| HTTP/1.1 | 6 | Limits parallel downloads |
|
|
619
|
+
| HTTP/2 | 1 (multiplexed) | All requests share one connection |
|
|
620
|
+
| HTTP/3 | 1 (multiplexed) | Same as HTTP/2, but over QUIC |
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
624
|
+
## Early Hints (103 Status Code)
|
|
625
|
+
|
|
626
|
+
### How It Works
|
|
627
|
+
|
|
628
|
+
The server sends a `103 Early Hints` response *before* the final `200 OK` response.
|
|
629
|
+
This uses the "server think-time" (while the server processes the request, queries
|
|
630
|
+
databases, renders templates) to tell the browser to start fetching critical
|
|
631
|
+
sub-resources.
|
|
632
|
+
|
|
633
|
+
```
|
|
634
|
+
Client Server
|
|
635
|
+
|---- GET /page.html ----------->|
|
|
636
|
+
| | (server starts processing)
|
|
637
|
+
|<--- 103 Early Hints -----------| Link: </style.css>; rel=preload; as=style
|
|
638
|
+
| | Link: </hero.webp>; rel=preload; as=image
|
|
639
|
+
| (browser starts fetching |
|
|
640
|
+
| style.css and hero.webp) |
|
|
641
|
+
| | (server finishes processing)
|
|
642
|
+
|<--- 200 OK --------------------| (full HTML response)
|
|
643
|
+
| |
|
|
644
|
+
| (CSS and image already |
|
|
645
|
+
| downloading or cached!) |
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
### Performance Impact
|
|
649
|
+
|
|
650
|
+
| Scenario | Without 103 | With 103 | Improvement |
|
|
651
|
+
|---------------------------------------|-------------|-------------|----------------|
|
|
652
|
+
| LCP (P75, desktop, Akamai customers) | Baseline | -300 ms | 30% faster |
|
|
653
|
+
| LCP (synthetic, image-heavy page) | Baseline | -20-30% | Significant |
|
|
654
|
+
| LCP image appearance | Baseline | 45% faster | Image-heavy |
|
|
655
|
+
|
|
656
|
+
Source: Akamai Early Hints prototype results
|
|
657
|
+
(https://www.akamai.com/blog/performance/akamai-103-early-hints-prototype-the-results-are-in);
|
|
658
|
+
Shopify Early Hints analysis
|
|
659
|
+
(https://performance.shopify.com/blogs/blog/early-hints-at-shopify)
|
|
660
|
+
|
|
661
|
+
### Important Caveats (2025)
|
|
662
|
+
|
|
663
|
+
Shopify's 2025 analysis revealed nuanced results:
|
|
664
|
+
|
|
665
|
+
- **Desktop**: Modest but consistent LCP improvements, especially with 1-3 preloaded
|
|
666
|
+
resources.
|
|
667
|
+
- **Mobile**: Early Hints can **slow down performance** on mobile devices. The
|
|
668
|
+
additional hints compete for limited mobile bandwidth and CPU.
|
|
669
|
+
- **Recommendation**: Preload only 1-3 truly critical resources. Validate impact
|
|
670
|
+
with real user monitoring (RUM) on both desktop and mobile cohorts.
|
|
671
|
+
|
|
672
|
+
### Browser and Server Support
|
|
673
|
+
|
|
674
|
+
| Component | Support Status |
|
|
675
|
+
|---------------|---------------------------------------------------|
|
|
676
|
+
| Chrome | Yes (since v103, June 2022) |
|
|
677
|
+
| Firefox | Yes (since v102, June 2022) |
|
|
678
|
+
| Safari | No (as of early 2026) |
|
|
679
|
+
| Edge | Yes (Chromium-based) |
|
|
680
|
+
| NGINX | Yes (since v1.27.3, 2024) |
|
|
681
|
+
| Cloudflare | Yes (automatic with Smart Early Hints) |
|
|
682
|
+
| Akamai | Yes (Early Hints feature) |
|
|
683
|
+
| Apache | Limited (via mod_http2) |
|
|
684
|
+
|
|
685
|
+
### Implementation
|
|
686
|
+
|
|
687
|
+
```nginx
|
|
688
|
+
# NGINX 103 Early Hints
|
|
689
|
+
location /page {
|
|
690
|
+
http2_push_preload on;
|
|
691
|
+
add_header Link "</style.css>; rel=preload; as=style" early;
|
|
692
|
+
add_header Link "</hero.webp>; rel=preload; as=image" early;
|
|
693
|
+
proxy_pass http://backend;
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
```javascript
|
|
698
|
+
// Node.js / Express
|
|
699
|
+
app.get('/page', (req, res) => {
|
|
700
|
+
// Send 103 Early Hints before processing
|
|
701
|
+
res.writeEarlyHints({
|
|
702
|
+
link: [
|
|
703
|
+
'</style.css>; rel=preload; as=style',
|
|
704
|
+
'</hero.webp>; rel=preload; as=image',
|
|
705
|
+
],
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// Continue with normal response processing
|
|
709
|
+
const data = await fetchDataFromDB();
|
|
710
|
+
res.render('page', { data });
|
|
711
|
+
});
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
## Common Bottlenecks
|
|
717
|
+
|
|
718
|
+
### 1. Too Many Third-Party Domains
|
|
719
|
+
|
|
720
|
+
**Problem**: The median website connects to **15-20 third-party domains** (HTTP Archive
|
|
721
|
+
2024). Each domain requires DNS + TCP + TLS setup (300-700 ms on first visit).
|
|
722
|
+
|
|
723
|
+
**Impact**: First visit page load increases by 1-3 seconds due to connection overhead
|
|
724
|
+
alone. Over 90% of web pages include at least one third-party resource.
|
|
725
|
+
|
|
726
|
+
**Fix**:
|
|
727
|
+
- Audit third-party scripts quarterly -- remove unused ones
|
|
728
|
+
- Self-host critical third-party resources (fonts, analytics libraries)
|
|
729
|
+
- Use `dns-prefetch` for domains you cannot eliminate
|
|
730
|
+
- Use `preconnect` for the 2-3 most critical third-party origins
|
|
731
|
+
- Set a domain budget: maximum 8-10 external domains per page
|
|
732
|
+
|
|
733
|
+
### 2. Uncompressed Resources
|
|
734
|
+
|
|
735
|
+
**Problem**: Serving text resources (HTML, CSS, JS, JSON, SVG) without compression.
|
|
736
|
+
|
|
737
|
+
**Impact**: A typical 300 KB JavaScript bundle compresses to 75 KB with gzip or 60 KB
|
|
738
|
+
with Brotli. Without compression, users download **4-5x more data** than necessary.
|
|
739
|
+
|
|
740
|
+
**Fix**:
|
|
741
|
+
- Enable Brotli compression on your server/CDN (with gzip fallback)
|
|
742
|
+
- Pre-compress static assets at build time with Brotli level 11
|
|
743
|
+
- Verify with `curl -H "Accept-Encoding: br, gzip" -I https://example.com/app.js`
|
|
744
|
+
- Check the `Content-Encoding` response header
|
|
745
|
+
|
|
746
|
+
### 3. Render-Blocking Requests
|
|
747
|
+
|
|
748
|
+
**Problem**: Synchronous CSS and JavaScript in `<head>` block first paint.
|
|
749
|
+
|
|
750
|
+
**Impact**: Every render-blocking resource adds at minimum 1 RTT (50-200 ms) to
|
|
751
|
+
First Contentful Paint. Tag managers loaded synchronously can inject additional
|
|
752
|
+
blocking scripts, compounding the problem.
|
|
753
|
+
|
|
754
|
+
**Fix**:
|
|
755
|
+
- Inline critical CSS (under 14 KB to fit in first TCP congestion window)
|
|
756
|
+
- Load non-critical CSS with `media` attributes or dynamic insertion
|
|
757
|
+
- Add `defer` or `async` to all non-critical scripts
|
|
758
|
+
- Move scripts to end of `<body>` if `defer` is not suitable
|
|
759
|
+
- Avoid synchronous script injection patterns
|
|
760
|
+
|
|
761
|
+
### 4. Waterfall Chains (Sequential Dependencies)
|
|
762
|
+
|
|
763
|
+
**Problem**: Resources that can only be discovered after a parent resource loads.
|
|
764
|
+
|
|
765
|
+
**Common chains**:
|
|
766
|
+
- CSS `@import` chains: 1 RTT per import depth
|
|
767
|
+
- JavaScript dynamic imports discovered at runtime
|
|
768
|
+
- Fonts referenced in CSS (discovered only after CSS parse)
|
|
769
|
+
- Images set via CSS `background-image`
|
|
770
|
+
|
|
771
|
+
**Impact**: A chain of depth 4 at 100 ms RTT adds **400 ms minimum** of pure wait time.
|
|
772
|
+
|
|
773
|
+
**Fix**:
|
|
774
|
+
- Flatten CSS `@import` into parallel `<link>` tags
|
|
775
|
+
- Use `<link rel="preload">` for fonts and critical images
|
|
776
|
+
- Use `<link rel="modulepreload">` for deep JS module chains
|
|
777
|
+
- Analyze chain depth in Lighthouse (target: depth <= 2)
|
|
778
|
+
|
|
779
|
+
### 5. Oversized Unoptimized Resources
|
|
780
|
+
|
|
781
|
+
**Problem**: Downloading resources larger than necessary.
|
|
782
|
+
|
|
783
|
+
**Examples**:
|
|
784
|
+
- 2 MB hero image when 200 KB WebP would suffice (10x waste)
|
|
785
|
+
- 500 KB JavaScript bundle when tree-shaking could produce 150 KB
|
|
786
|
+
- Full font family (400 KB) when subset would be 30 KB
|
|
787
|
+
|
|
788
|
+
**Fix**:
|
|
789
|
+
- Serve responsive images with `srcset` and `sizes`
|
|
790
|
+
- Use modern formats (WebP, AVIF) with `<picture>` fallback
|
|
791
|
+
- Tree-shake and code-split JavaScript bundles
|
|
792
|
+
- Subset fonts to only needed character ranges
|
|
793
|
+
|
|
794
|
+
---
|
|
795
|
+
|
|
796
|
+
## Anti-Patterns
|
|
797
|
+
|
|
798
|
+
### 1. Preloading Everything
|
|
799
|
+
|
|
800
|
+
```html
|
|
801
|
+
<!-- ANTI-PATTERN: preloading 10+ resources -->
|
|
802
|
+
<link rel="preload" href="/font1.woff2" as="font" crossorigin>
|
|
803
|
+
<link rel="preload" href="/font2.woff2" as="font" crossorigin>
|
|
804
|
+
<link rel="preload" href="/font3.woff2" as="font" crossorigin>
|
|
805
|
+
<link rel="preload" href="/hero.webp" as="image">
|
|
806
|
+
<link rel="preload" href="/logo.svg" as="image">
|
|
807
|
+
<link rel="preload" href="/app.js" as="script">
|
|
808
|
+
<link rel="preload" href="/vendor.js" as="script">
|
|
809
|
+
<link rel="preload" href="/utils.js" as="script">
|
|
810
|
+
<link rel="preload" href="/style.css" as="style">
|
|
811
|
+
<link rel="preload" href="/theme.css" as="style">
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
**Why it hurts**: Preload is a mandatory, high-priority fetch. Preloading 10 resources
|
|
815
|
+
means 10 high-priority fetches compete for bandwidth simultaneously. The truly critical
|
|
816
|
+
resources (LCP image, main CSS) get delayed because bandwidth is shared with less
|
|
817
|
+
important resources.
|
|
818
|
+
|
|
819
|
+
**Rule of thumb**: Preload a maximum of **2-5 resources**. If you need more, you likely
|
|
820
|
+
have an architecture problem to solve instead.
|
|
821
|
+
|
|
822
|
+
### 2. Not Using HTTP/2 (or Actively Fighting It)
|
|
823
|
+
|
|
824
|
+
**Problem**: Domain sharding (splitting resources across cdn1.example.com,
|
|
825
|
+
cdn2.example.com, etc.) was an HTTP/1.1 optimization to bypass the 6-connection limit.
|
|
826
|
+
Under HTTP/2, it is actively harmful -- it prevents connection coalescing and forces
|
|
827
|
+
multiple TCP connections where one would suffice.
|
|
828
|
+
|
|
829
|
+
**Fix**: Consolidate assets onto a single domain (or 2 at most). Let HTTP/2
|
|
830
|
+
multiplexing handle concurrency.
|
|
831
|
+
|
|
832
|
+
### 3. Ignoring Resource Priorities
|
|
833
|
+
|
|
834
|
+
**Problem**: Loading all images at the same priority. The LCP image and a footer
|
|
835
|
+
decorative icon have identical priority by default.
|
|
836
|
+
|
|
837
|
+
**Fix**: Use `fetchpriority="high"` on the LCP image, `fetchpriority="low"` +
|
|
838
|
+
`loading="lazy"` on below-the-fold images.
|
|
839
|
+
|
|
840
|
+
### 4. Synchronous Third-Party Scripts in Head
|
|
841
|
+
|
|
842
|
+
```html
|
|
843
|
+
<!-- ANTI-PATTERN -->
|
|
844
|
+
<head>
|
|
845
|
+
<script src="https://tag-manager.example.com/gtm.js"></script>
|
|
846
|
+
<script src="https://analytics.example.com/tracker.js"></script>
|
|
847
|
+
<script src="https://chat.example.com/widget.js"></script>
|
|
848
|
+
</head>
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
**Impact**: Each script blocks rendering. With 3 third-party scripts, first paint is
|
|
852
|
+
delayed by **300-900 ms** (3 x 1-3 RTTs including DNS+TCP+TLS for new domains).
|
|
853
|
+
|
|
854
|
+
**Fix**: Add `async` or `defer`, move to end of `<body>`, or load via a tag manager
|
|
855
|
+
with async loading.
|
|
856
|
+
|
|
857
|
+
### 5. Missing Compression
|
|
858
|
+
|
|
859
|
+
Serving text resources without `Content-Encoding: br` or `Content-Encoding: gzip`.
|
|
860
|
+
This is the single highest-impact fix for most sites -- enabling compression
|
|
861
|
+
typically reduces total page weight by **60-80%** for text resources.
|
|
862
|
+
|
|
863
|
+
### 6. No Cache Headers on Static Assets
|
|
864
|
+
|
|
865
|
+
```
|
|
866
|
+
# ANTI-PATTERN: No caching
|
|
867
|
+
Cache-Control: no-store
|
|
868
|
+
|
|
869
|
+
# CORRECT: Immutable assets with content hashes
|
|
870
|
+
Cache-Control: public, max-age=31536000, immutable
|
|
871
|
+
|
|
872
|
+
# CORRECT: HTML pages
|
|
873
|
+
Cache-Control: no-cache
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
Without proper cache headers, browsers re-download unchanged resources on every visit.
|
|
877
|
+
With a 1-year `max-age` and content-hashed filenames, repeat visits download **0 bytes**
|
|
878
|
+
for unchanged static assets.
|
|
879
|
+
|
|
880
|
+
---
|
|
881
|
+
|
|
882
|
+
## Before/After Waterfall Diagrams
|
|
883
|
+
|
|
884
|
+
### Example 1: Unoptimized E-Commerce Product Page
|
|
885
|
+
|
|
886
|
+
```
|
|
887
|
+
BEFORE (Total load: 4.8 s)
|
|
888
|
+
===========================
|
|
889
|
+
Time: 0ms 500ms 1000ms 1500ms 2000ms 2500ms 3000ms 3500ms 4000ms 4800ms
|
|
890
|
+
|--------|--------|--------|--------|--------|--------|--------|--------|--------|
|
|
891
|
+
|
|
892
|
+
HTML |========| 200ms
|
|
893
|
+
CSS . |==========| 350ms (blocked by HTML)
|
|
894
|
+
@import. |========| 280ms (blocked by CSS)
|
|
895
|
+
Font . |==========| 350ms (blocked by @import)
|
|
896
|
+
GTM |==================| 500ms (sync, blocking)
|
|
897
|
+
GTM-sub. |==============| 400ms (injected by GTM)
|
|
898
|
+
Hero . |================| 500ms (discovered late)
|
|
899
|
+
LCP . * 2800ms (LCP event)
|
|
900
|
+
JS |========================| 650ms (sync, blocking)
|
|
901
|
+
API . |==============| 450ms (blocked by JS)
|
|
902
|
+
Images . |========================| 700ms (no lazy loading)
|
|
903
|
+
|
|
904
|
+
Chain depth: 4 (HTML->CSS->@import->Font)
|
|
905
|
+
Domains: 12
|
|
906
|
+
Render-blocking: 3 resources
|
|
907
|
+
Compression: gzip only
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
```
|
|
911
|
+
AFTER (Total load: 1.9 s)
|
|
912
|
+
=========================
|
|
913
|
+
Time: 0ms 500ms 1000ms 1500ms 1900ms
|
|
914
|
+
|--------|--------|--------|--------|
|
|
915
|
+
|
|
916
|
+
HTML |======| 180ms (Brotli compressed)
|
|
917
|
+
CSS |======| 180ms (inlined critical, preloaded full)
|
|
918
|
+
Font |========| 250ms (preloaded, starts with HTML)
|
|
919
|
+
Hero |==========| 300ms (preloaded, fetchpriority=high)
|
|
920
|
+
LCP . * 500ms (LCP event -- 78% faster)
|
|
921
|
+
GTM . |==========| 350ms (async, fetchpriority=low)
|
|
922
|
+
JS . |========| 250ms (deferred, Brotli compressed)
|
|
923
|
+
API . |======| 200ms (fetchpriority=high)
|
|
924
|
+
Images . |====| 150ms (lazy loaded, below fold)
|
|
925
|
+
|
|
926
|
+
Chain depth: 1 (everything parallel)
|
|
927
|
+
Domains: 4 (consolidated)
|
|
928
|
+
Render-blocking: 0 resources
|
|
929
|
+
Compression: Brotli (level 11 static, level 5 dynamic)
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
**Result: LCP improved from 2.8 s to 0.5 s (82% improvement). Total load from 4.8 s
|
|
933
|
+
to 1.9 s (60% improvement).**
|
|
934
|
+
|
|
935
|
+
### Example 2: Blog/Content Site with 103 Early Hints
|
|
936
|
+
|
|
937
|
+
```
|
|
938
|
+
BEFORE (LCP: 3.2 s)
|
|
939
|
+
====================
|
|
940
|
+
Time: 0ms 500ms 1000ms 1500ms 2000ms 2500ms 3000ms 3200ms
|
|
941
|
+
|--------|--------|--------|--------|--------|--------|--------|
|
|
942
|
+
|
|
943
|
+
DNS |==| 80ms
|
|
944
|
+
TCP . |==| 100ms
|
|
945
|
+
TLS . |====| 200ms
|
|
946
|
+
HTML . |==========| 400ms (server processing)
|
|
947
|
+
CSS . |========| 300ms
|
|
948
|
+
Font . |========| 300ms
|
|
949
|
+
Image . |============| 450ms
|
|
950
|
+
LCP . * 3200ms
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
```
|
|
954
|
+
AFTER (LCP: 1.8 s)
|
|
955
|
+
===================
|
|
956
|
+
Time: 0ms 500ms 1000ms 1500ms 1800ms
|
|
957
|
+
|--------|--------|--------|--------|
|
|
958
|
+
|
|
959
|
+
DNS |==| 80ms
|
|
960
|
+
TCP . |==| 100ms
|
|
961
|
+
TLS . |====| 200ms
|
|
962
|
+
103 . | (Early Hints sent immediately)
|
|
963
|
+
CSS . |========| 300ms (started during server think-time)
|
|
964
|
+
Font . |========| 300ms (started during server think-time)
|
|
965
|
+
Image . |============| 450ms (started during server think-time)
|
|
966
|
+
HTML . |==========| 400ms (server processing, parallel)
|
|
967
|
+
LCP . * 1800ms
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
**Result: LCP improved from 3.2 s to 1.8 s (44% improvement) by overlapping resource
|
|
971
|
+
fetches with server processing time.**
|
|
972
|
+
|
|
973
|
+
---
|
|
974
|
+
|
|
975
|
+
## Decision Tree: Resource Prioritization
|
|
976
|
+
|
|
977
|
+
Use this flowchart to determine how to handle each resource on your page.
|
|
978
|
+
|
|
979
|
+
```
|
|
980
|
+
START: Is this resource needed for the current page?
|
|
981
|
+
|
|
|
982
|
+
+-- NO --> Is it needed for the next likely page?
|
|
983
|
+
| |
|
|
984
|
+
| +-- YES --> <link rel="prefetch"> (idle priority)
|
|
985
|
+
| +-- NO --> Do not load it at all
|
|
986
|
+
|
|
|
987
|
+
+-- YES --> Is it above the fold / critical for first render?
|
|
988
|
+
|
|
|
989
|
+
+-- NO --> Does the user need to scroll to see it?
|
|
990
|
+
| |
|
|
991
|
+
| +-- YES (image) --> loading="lazy" + fetchpriority="low"
|
|
992
|
+
| +-- YES (script) --> <script defer> or <script async>
|
|
993
|
+
| +-- YES (CSS) --> media="print" onload trick or dynamic insert
|
|
994
|
+
|
|
|
995
|
+
+-- YES --> Is it the LCP element?
|
|
996
|
+
|
|
|
997
|
+
+-- YES --> Is it an image?
|
|
998
|
+
| |
|
|
999
|
+
| +-- YES --> fetchpriority="high"
|
|
1000
|
+
| | + <link rel="preload"> if CSS bg-image
|
|
1001
|
+
| | + Serve WebP/AVIF, responsive sizes
|
|
1002
|
+
| |
|
|
1003
|
+
| +-- NO (text) --> Inline critical CSS
|
|
1004
|
+
| + preload fonts
|
|
1005
|
+
|
|
|
1006
|
+
+-- NO (but above fold) -->
|
|
1007
|
+
|
|
|
1008
|
+
+-- Is it a font? --> <link rel="preload" as="font" crossorigin>
|
|
1009
|
+
+-- Is it CSS? --> Inline critical portion (<14 KB)
|
|
1010
|
+
+-- Is it JS? --> <script defer> (or async if independent)
|
|
1011
|
+
+-- Is it from third-party origin?
|
|
1012
|
+
|
|
|
1013
|
+
+-- Critical? --> <link rel="preconnect">
|
|
1014
|
+
+-- Non-critical? --> <link rel="dns-prefetch">
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
### Quick Reference: Priority Assignment
|
|
1018
|
+
|
|
1019
|
+
| Resource | fetchpriority | loading | rel hint | Script attr |
|
|
1020
|
+
|---------------------------------|---------------|----------|----------------|-------------|
|
|
1021
|
+
| LCP hero image | high | eager | preload | -- |
|
|
1022
|
+
| Above-fold non-LCP image | (default) | eager | -- | -- |
|
|
1023
|
+
| Below-fold image | low | lazy | -- | -- |
|
|
1024
|
+
| Critical CSS | -- | -- | preload (full) | -- |
|
|
1025
|
+
| Non-critical CSS | -- | -- | prefetch | -- |
|
|
1026
|
+
| Main app JS bundle | high | -- | -- | defer |
|
|
1027
|
+
| Analytics / tracking JS | low | -- | -- | async |
|
|
1028
|
+
| Chat widget JS | low | -- | -- | defer |
|
|
1029
|
+
| Web font (above fold) | (default) | -- | preload | -- |
|
|
1030
|
+
| Third-party critical origin | -- | -- | preconnect | -- |
|
|
1031
|
+
| Third-party non-critical origin | -- | -- | dns-prefetch | -- |
|
|
1032
|
+
| Next-page JS bundle | -- | -- | prefetch | -- |
|
|
1033
|
+
| Deep ES module dependency | -- | -- | modulepreload | -- |
|
|
1034
|
+
|
|
1035
|
+
---
|
|
1036
|
+
|
|
1037
|
+
## Optimization Checklist
|
|
1038
|
+
|
|
1039
|
+
Use this checklist to audit any web page for network performance issues:
|
|
1040
|
+
|
|
1041
|
+
```
|
|
1042
|
+
PROTOCOL
|
|
1043
|
+
[ ] HTTP/2 or HTTP/3 enabled
|
|
1044
|
+
[ ] Alt-Svc header advertises HTTP/3 if available
|
|
1045
|
+
[ ] QUIC (UDP 443) not blocked by firewall
|
|
1046
|
+
|
|
1047
|
+
COMPRESSION
|
|
1048
|
+
[ ] Brotli enabled for text resources (HTML, CSS, JS, JSON, SVG)
|
|
1049
|
+
[ ] Gzip enabled as fallback
|
|
1050
|
+
[ ] Static assets pre-compressed at Brotli level 11
|
|
1051
|
+
[ ] Content-Encoding header present in responses
|
|
1052
|
+
|
|
1053
|
+
RESOURCE HINTS
|
|
1054
|
+
[ ] preconnect on 2-3 critical third-party origins
|
|
1055
|
+
[ ] dns-prefetch on remaining third-party domains
|
|
1056
|
+
[ ] preload on LCP image (if CSS background or late-discovered)
|
|
1057
|
+
[ ] preload on critical fonts
|
|
1058
|
+
[ ] No more than 5 total preload hints
|
|
1059
|
+
[ ] modulepreload on critical deep JS module imports
|
|
1060
|
+
|
|
1061
|
+
FETCH PRIORITY
|
|
1062
|
+
[ ] fetchpriority="high" on LCP image (1 resource only)
|
|
1063
|
+
[ ] fetchpriority="low" on below-fold images
|
|
1064
|
+
[ ] loading="lazy" on all below-fold images
|
|
1065
|
+
|
|
1066
|
+
SCRIPTS
|
|
1067
|
+
[ ] No synchronous scripts in <head> (except critical inline)
|
|
1068
|
+
[ ] defer or async on all external scripts
|
|
1069
|
+
[ ] Third-party scripts audited quarterly
|
|
1070
|
+
[ ] Tag manager loaded async
|
|
1071
|
+
|
|
1072
|
+
CSS
|
|
1073
|
+
[ ] Critical CSS inlined (<14 KB)
|
|
1074
|
+
[ ] Full CSS loaded via preload with onload swap
|
|
1075
|
+
[ ] No CSS @import chains (flattened to parallel <link> tags)
|
|
1076
|
+
|
|
1077
|
+
CACHING
|
|
1078
|
+
[ ] Cache-Control headers on all static assets
|
|
1079
|
+
[ ] Content-hashed filenames for immutable caching
|
|
1080
|
+
[ ] Service worker with cache-first for static assets
|
|
1081
|
+
[ ] Cache hit ratio monitored (target: >85%)
|
|
1082
|
+
|
|
1083
|
+
EARLY HINTS
|
|
1084
|
+
[ ] 103 Early Hints for 1-3 critical resources (if server supports)
|
|
1085
|
+
[ ] Validated with RUM on both desktop and mobile
|
|
1086
|
+
[ ] Not over-hinting (max 3 resources)
|
|
1087
|
+
|
|
1088
|
+
CONNECTION
|
|
1089
|
+
[ ] Domains consolidated (target: <8 external domains)
|
|
1090
|
+
[ ] Keep-alive enabled with appropriate timeout
|
|
1091
|
+
[ ] Connection pooling configured for backend services
|
|
1092
|
+
|
|
1093
|
+
MONITORING
|
|
1094
|
+
[ ] RUM tracking for LCP, FCP, TTFB, CLS, INP
|
|
1095
|
+
[ ] Lighthouse CI in deployment pipeline
|
|
1096
|
+
[ ] Critical request chain depth <= 2
|
|
1097
|
+
[ ] Waterfall analysis on key pages monthly
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
---
|
|
1101
|
+
|
|
1102
|
+
## Sources
|
|
1103
|
+
|
|
1104
|
+
- [Cloudflare: HTTP/3 vs HTTP/2 Performance](https://blog.cloudflare.com/http-3-vs-http-2/)
|
|
1105
|
+
- [DebugBear: HTTP/3 vs HTTP/2 Performance](https://www.debugbear.com/blog/http3-vs-http2-performance)
|
|
1106
|
+
- [Request Metrics: HTTP/3 is Fast](https://requestmetrics.com/web-performance/http3-is-fast/)
|
|
1107
|
+
- [The New Stack: HTTP/3 in the Wild](https://thenewstack.io/http-3-in-the-wild-why-it-beats-http-2-where-it-matters-most/)
|
|
1108
|
+
- [web.dev: Resource Hints](https://web.dev/learn/performance/resource-hints)
|
|
1109
|
+
- [DebugBear: Browser Resource Hints](https://www.debugbear.com/blog/resource-hints-rel-preload-prefetch-preconnect)
|
|
1110
|
+
- [NitroPack: Resource Hints Performance Optimization](https://nitropack.io/blog/resource-hints-performance-optimization/)
|
|
1111
|
+
- [MDN: dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/dns-prefetch)
|
|
1112
|
+
- [web.dev: Fetch Priority API](https://web.dev/articles/fetch-priority)
|
|
1113
|
+
- [DebugBear: fetchpriority Attribute](https://www.debugbear.com/blog/fetchpriority-attribute)
|
|
1114
|
+
- [DebugBear: Avoid Overusing fetchpriority=high](https://www.debugbear.com/blog/avoid-overusing-fetchpriority-high)
|
|
1115
|
+
- [imkev.dev: Fetch Priority and Optimizing LCP](https://imkev.dev/fetchpriority-opportunity)
|
|
1116
|
+
- [web.dev: Service Worker Caching and HTTP Caching](https://web.dev/articles/service-worker-caching-and-http-caching)
|
|
1117
|
+
- [MDN: PWA Caching](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Guides/Caching)
|
|
1118
|
+
- [Paul Calvano: Choosing Between gzip, Brotli, and Zstandard](https://paulcalvano.com/2024-03-19-choosing-between-gzip-brotli-and-zstandard-compression/)
|
|
1119
|
+
- [DebugBear: HTTP Compression Gzip Brotli](https://www.debugbear.com/blog/http-compression-gzip-brotli)
|
|
1120
|
+
- [IO River: Gzip vs Brotli Compression Performance](https://www.ioriver.io/blog/gzip-vs-brotli-compression-performance)
|
|
1121
|
+
- [DebugBear: Avoid Chaining Critical Requests](https://www.debugbear.com/blog/avoid-chaining-critical-requests)
|
|
1122
|
+
- [DebugBear: Optimizing the Critical Rendering Path](https://www.debugbear.com/blog/optimizing-the-critical-rendering-path)
|
|
1123
|
+
- [HTTP Archive: 2024 Web Almanac - Performance](https://almanac.httparchive.org/en/2024/performance)
|
|
1124
|
+
- [Akamai: Early Hints Prototype Results](https://www.akamai.com/blog/performance/akamai-103-early-hints-prototype-the-results-are-in)
|
|
1125
|
+
- [Shopify: Early Hints at Shopify](https://performance.shopify.com/blogs/blog/early-hints-at-shopify)
|
|
1126
|
+
- [Cloudflare: Early Hints Performance](https://blog.cloudflare.com/early-hints-performance/)
|
|
1127
|
+
- [NGINX: 103 Early Hints Support](https://blog.nginx.org/blog/nginx-introduces-support-103-early-hints)
|
|
1128
|
+
- [MDN: modulepreload](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/modulepreload)
|
|
1129
|
+
- [web.dev: Preload Modules](https://web.dev/articles/modulepreload)
|
|
1130
|
+
- [HAProxy: HTTP Keep-Alive and Connection Pooling](https://www.haproxy.com/blog/http-keep-alive-pipelining-multiplexing-and-connection-pooling)
|
|
1131
|
+
- [Microsoft: HTTP Connection Pooling](https://devblogs.microsoft.com/premier-developer/the-art-of-http-connection-pooling-how-to-optimize-your-connections-for-peak-performance/)
|
|
1132
|
+
- [F5/NGINX: HTTP Keepalives and Web Performance](https://www.f5.com/company/blog/nginx/http-keepalives-and-web-performance)
|
|
1133
|
+
- [NitroPack: Core Web Vitals Strategy 2025](https://nitropack.io/blog/core-web-vitals-strategy/)
|