-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[Proposal] Optimize the index.js
#23461
Comments
Can probably replace ready with DOMContentLoaded, to lessen our jQuery dependency. Oh, and the syntax in use is apparently deprecated as of jQuery 3.0.
Is this true for pages without a heatmap as well? If so, we should definitely add early exit to that function. Generally it should be noted that heatmap data generation is very inefficient on server-side too. |
I agree we can refactor, but It's not related to this problem. The problem is many
No Other You could take a try. const fns = [];
let last = performance.now();
function record(s) {
const now = performance.now();
fns.push({fn:s, t: now-last});
last = now;
}
initGlobalCommon();record(`initGlobalCommon()`);
...
initUserSettings();record(`initUserSettings()`);
initViewedCheckboxListenerFor();record(`initViewedCheckboxListenerFor()`);
fns.sort((a, b) => b.t - a.t).forEach((f) => console.log(f.fn, f.t.toFixed(3))); |
Can we split index.js, at least we can have an admin.js which will only include admin related js |
At the moment, Find the root problem and focus on the root problem. |
Which measurement tool did you use? |
Home-made JS in #23461 (comment) I push the test code to https://github.com/wxiaoguang/gitea/tree/test-js-slow |
Note this is a separate, second instance of tippy.js because https://github.com/razorness/vue3-calendar-heatmap has its own dependency on it. So essentially we init tippy twice because of it. I guess a better solution may be to incorporate that module into first-party code. |
Looking through that module, it seem to create a tippy instance for each day, so 365 tippy instances. I think this is reason why it's slow to init. A better approach may be to just use |
vue3-calendar-heatmap has released 2.0.2 with lazy tippy init. According to my test, the |
Out-dated and there is no planned work in near future. |
Feature Description
This is an idea for public (feel free to take it or work on it).
Gitea's
index.js
logic becomes more and more complex. On my MacBook Pro, almost every page loading says:I think the
setTimeout
is actually the$(document).ready(() => {})
call inindex.js
, it's too complex. If that$(document).ready()
is commented out, there is no warning anymore.So, I think in the future, it's better to avoid making the
index.js
do too much slowinit
calls, instead, many calls should be optimized (by various approaches)Some clues
initHeatmap
takes around 100ms (update: vue3-calendar-heatmap 2.0.2, the time decreases from 100ms to 50ms)initGlobalCommon
is also slow, if there are many elementsinitRepoTopicBar
seems unnecessarily slowThe text was updated successfully, but these errors were encountered: