reactjs / reactjs/react.dev

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

未关闭
#2,156 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
11.8k
派生
7.9k
平均合并
1 天 11 小时
30 天内合并 PR
11

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

该报告提到了 localhost:3000 上的主页、特定路由的组件以及旧的 jQuery JavaScript 文件。首先确定这个问题是否应归入 React 文档,并在加载主页时检查 Network 选项卡;当 issue 有明确记录的答案,或被转至更合适的论坛时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, jquery, react
领域
frontend, web-dev
Issue 类型
文档
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。