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

Improve JS loading #335

Merged
merged 4 commits into from
Jul 10, 2024
Merged

Improve JS loading #335

merged 4 commits into from
Jul 10, 2024

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Jul 10, 2024

Removing Prism.js

Before we moved to Torchlight we were using Prism.js to do highlighting.

We are still shipping Prism.js to the client even though we are not using it.

This means we ship ~20KB less JS to the client.

Removing unused vendor JS

  • Removes the unused babel config.
  • Removes the unused vendor/algoliasearch.js. We install this via NPM now.
  • Removes the unused vendor/hogan.js. I don't even know what this is, but we don't use it anywhere I can see.
  • Removes the unused vendor/typeahead.js. We don't seem to use this anywhere.

Additional build size improvements

app.js now builds to 157.34KB down from 169.14KB
docs.js now builds to 14.21KB down from 22.03KB
accessibility.js has been combined into docs.js to reduce the request count.

Overall reduction of ~22KB of JS.

Additional bundle loading improvements.

  • Removes an additional asset request from the marketing pages.
  • Removes an additional asset request from the docs pages.
  • Makes a lazy request on the docs page eager, which should mean improved load times.
  • Reorganizes the assets so that the marketing pages only load the JS they needs, i.e., it no longer loads the copy to clipboard, theming, and accessibility JS which are only used on the /docs pages.

@timacdonald timacdonald changed the title Remove unused JS Improve JS loading Jul 10, 2024
Comment on lines -3 to -5

import './clipboard';
import './components/search';
Copy link
Member Author

Choose a reason for hiding this comment

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

These are loaded via docs.js as they are not needed on non-docs pages.

@timacdonald timacdonald marked this pull request as ready for review July 10, 2024 07:21
@taylorotwell taylorotwell merged commit 22f6319 into master Jul 10, 2024
1 check passed
@taylorotwell taylorotwell deleted the cleanup branch July 10, 2024 19:02
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