reactjs / reactjs/react.dev

Is it possible to load specific files only when the current route requires them?

Open
#2,156 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Hi. I have an app that uses old .js files from a previous development of my website (in jQuery) which I'm introducing to this project as I'm redesigning my website and only want to load the old apps I made without having to go through the ordeal of re-coding them again to fully match ReactJS standards. It all works, however since each of these apps used a separate .js file to function, I have pasted them into the project as new files, and now when I load the homepage (localhost:3000), all the resources that are mentioned on these javascript files are loaded along with it (even if only a few bytes of each), not on the page body, but on the Network tab of the Chrome developer tools, and I assume into a similar location in other browsers, which would consume memory. Is there a way to tell React not to load these specific files unless the component that uses functions from them requires them?

Is this even the right place to ask this question? Please let me know, and I'll close the issue and ask in a more appropriate location

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report refers to the homepage at localhost:3000, route-specific components, and old jQuery JavaScript files. Start by determining whether this question belongs in the React documentation and by checking the Network tab while loading the homepage; done means the issue has a clear documented answer or is redirected to a more appropriate forum.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery, react
Domain
frontend, web-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.