-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add doc about native Next.js optimisations
- Loading branch information
1 parent
ec66fef
commit 620c8c9
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Next.js pages | ||
|
||
[Official documentation](https://nextjs.org/docs/basic-features/pages) | ||
|
||
## Native optimisations | ||
|
||
Next.js automatically optimise the page client build based on whether they implement `getStaticProps` (SSG) or `getServerSideProps` (SSR). | ||
|
||
For instance, all code within `getStaticProps` and `getServerSideProps` is automatically stripped from the browser bundle. | ||
But, it's also the case for top-level `import` that are only used within those functions. | ||
|
||
### Visualise bundle optimisation | ||
|
||
[https://next-code-elimination.now.sh/](https://next-code-elimination.now.sh/) will help you visualise the difference between the code you write and what's actually bundled into the client. | ||
|
||
Example with: | ||
- [https://next-code-elimination.now.sh/s/hc9SWg_fj]([locale]/examples/pageTemplateSSG) | ||
- [https://next-code-elimination.now.sh/s/M0oIDdQJ2]([locale]/examples/pageTemplateSSR) | ||
- [https://next-code-elimination.now.sh/s/nejeyE9MH]([locale]/examples/native-features/example-with-ssg-and-fallback/[albumId]) | ||
|
||
> You'll notice for both those files that server-side module imports such as `ApolloQueryResult` are completely stripped from the client-side build. | ||
> | ||
> Also, for `[albumId]`, relative imports such as `songs` are also automatically stripped! |
This file contains 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