Draft
Conversation
This commit implements several performance improvements for the protein detail page based on Lighthouse audit findings: 1. Database Query Optimization: - Add prefetch_related for references, transitions, and bleach_measurements - Add select_related for parent_organism and lineage relations - Reduces N+1 queries on protein detail page 2. Resource Hints: - Add preconnect/dns-prefetch for Google Analytics domains - Add preconnect/dns-prefetch for Algolia search API - Improves initial connection time for third-party resources 3. JavaScript Optimization: - Extract inline scripts from protein_detail.html to protein_page.js - Convert lineage chart to use IntersectionObserver for lazy loading - Lineage chart now only loads when scrolled into view (200px threshold) - Reduces initial JavaScript parse/execution time 4. Code Quality: - Replace inline mutation toggle function with reusable external function - Improve error handling for lineage chart loading failures - Better separation of concerns between template and JavaScript Expected Impact: - Reduced database queries (fewer round trips) - Faster third-party resource loading (earlier DNS resolution) - Reduced initial JavaScript execution (deferred lineage chart) - Smaller HTML payload (extracted inline scripts)
GA4 tracking beacons to google-analytics.com happen async after page load, so preconnect provides minimal benefit. Only googletagmanager.com needs preconnect since it's loaded synchronously during initial render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit implements several performance improvements for the protein detail page based on Lighthouse audit findings:
Database Query Optimization:
Resource Hints:
JavaScript Optimization:
Code Quality:
Expected Impact: