Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move custom styles to root App file(_app.js) #1764

Merged
merged 13 commits into from
Sep 15, 2023
Merged

Conversation

ElijahAhianyo
Copy link
Collaborator

@ElijahAhianyo ElijahAhianyo commented Sep 6, 2023

In this PR, we enhance maintainability and optimize the loading performance of our application. We've moved custom styles from the <head> tag in _document.js to _app.js. Additionally, all stylesheets and fonts are now consolidated into a root stylesheet (styles.css) at .web/styles/styles.css, which is imported into _app.js. Please note that the actual impact on performance may vary based on specific factors.

Changes Made

  • Relocated Custom Styles: Custom styles, formerly in the <head> tag in _document.js, are now in _app.js. This follows Next.js best practices, reducing HTTP requests during initial page load and enabling efficient style caching.

  • Consolidated Stylesheets and Fonts: All stylesheets and fonts are consolidated into a root stylesheet (styles.css). This streamlines our codebase, simplifies styling management, and ensures browser caching for improved performance.

Caching Considerations

Previously, styles in _document.js were not efficiently cached, except when served from a CDN. Moving styles to _app.js and consolidating them into a root stylesheet ensures efficient loading and caching, resulting in faster subsequent page loads.

Performance Benefits:

  • Varied Gain: The performance gain achieved by this change may vary significantly based on the size of the stylesheet. Smaller stylesheets may show minimal improvement, while larger stylesheets are likely to experience more noticeable gains.

  • Reduced HTTP Requests: Consolidating styles minimizes initial HTTP requests, further optimizing performance.

  • Simplified Maintenance: Centralizing styles simplifies maintenance and updates as the application evolves.

Additional Notes:

This change aligns with Next.js best practices, leveraging browser caching. It also streamlines our codebase by consolidating styles into a root stylesheet for improved maintainability.

@ElijahAhianyo ElijahAhianyo changed the title Move custom styles to root App file(_app.js) [WIP]Move custom styles to root App file(_app.js) Sep 7, 2023
@ElijahAhianyo
Copy link
Collaborator Author

Pipeline needs reflex-dev/reflex-web#202 merged to pass

@ElijahAhianyo ElijahAhianyo changed the title [WIP]Move custom styles to root App file(_app.js) Move custom styles to root App file(_app.js) Sep 13, 2023
@ElijahAhianyo ElijahAhianyo marked this pull request as ready for review September 14, 2023 07:47
reflex/compiler/compiler.py Show resolved Hide resolved
reflex/compiler/compiler.py Outdated Show resolved Hide resolved
reflex/compiler/compiler.py Outdated Show resolved Hide resolved
reflex/compiler/utils.py Show resolved Hide resolved
reflex/compiler/utils.py Show resolved Hide resolved
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@picklelo picklelo merged commit 74d227d into main Sep 15, 2023
35 checks passed
@picklelo picklelo deleted the elijah/nextjs-app-root branch September 16, 2023 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants