Ooker
Ooker12mo ago

Slow loading time on localhost

As discussed in https://discord.com/channels/684898665143206084/991511118524715139/1193585623710310473, my simple app is loading slow, even at localhost. Here the page takes a whole minute to finish. What make an app load slow? How can I identify which process consume how much time?
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
No description
14 Replies
Deno AI Helper
Deno AI Helper12mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on your message, there are a few general tips I can provide that might help you identify the cause of the slow loading time. 1. Check for Network Issues: Even though you're running on localhost, network configuration or firewall software could potentially cause delays. 2. Inspect Your Code for Performance Bottlenecks: Look for any loops or recursive functions that could be running more times than necessary, or any heavy computations that could be optimized. 3. Use Profiling Tools: Deno has built-in tooling for profiling, such as deno profile, which can help you identify which parts of your code are consuming the most time. 4. Check for External Resource Loading: If your app is loading external resources, such as databases, APIs, or large files, these could be the source of the delay. 5. Console Timing Functions: You can use console.time() and console.timeEnd() to measure the time it takes for certain parts of your code to execute. 6. Review Middleware or Frameworks: If you're using any middleware or frameworks with Deno, ensure they are not causing the slowdown. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If you continue to experience issues, you might want to consider reaching out to the Deno community for more specific guidance.
marvinh.
marvinh.12mo ago
That seems unreasonably slow. If you open the task manager and check the overall memory and cpu usage of your system. Could it be that another process unrelated to deno/fresh is consuming all system resources? If that's not the case, another thing to try is to profile the server code to see where CPU time is spent. This can be done by running a modified version of the start task: 1. Run deno run --inspect-brk -A --watch=static/,routes/ dev.ts 2. Open Chrome 3. Go to chrome://inspect (it's an internal chrome website) 4. Wait until an entry with "Deno" in the name appears, should happen after a few seconds and click "inspect". This opens an instance of Chrome Devtools attached to the deno process 5. In the Devtools go to the performance tab and press the record button 6. Go to your site as usual and refresh it 7. Stop the performance recording and check where time is spent
Ooker
OokerOP12mo ago
I use firefox. In my understanding Firefox's about:debugging is equivalent to Chrome's chrome://inspect. I run the command but don't see any entry named Deno appears
No description
Ooker
OokerOP12mo ago
is it that it should be in the service workers category? the problem doesn't happen in my phone. I restart Firefox in troubleshoot mode to disable all plugins and scripts and the loading is normal again. So I get that I can disable them one-by-one until the troublesome plugin is isolated however, just for the sake of broaden my knowledge, do you know why the Firefox debugger is unable to detect Deno?
marvinh.
marvinh.12mo ago
No that's incorrect. Deno is built around v8 the JS engine used in Chrome. Firefox uses a different JS engine called gecko and thus has a different debug API. They are not equivalent. Only Chrome can attach a debugger to a v8 and by extension a deno process.
Ooker
OokerOP12mo ago
that's what I have known but now it's more interesting than when I first knew it. Is there any article on why Ryan chose V8 and not Gecko? Node's legacy?
marvinh.
marvinh.12mo ago
at the time and to this day v8 is the most advanced and feature packed JS engine out there. It also works on all major OSes the question is rather why wouldn't you pick v8?
Ooker
OokerOP12mo ago
support Firefox as it seems to be the last representation for browser diversity, and the inertia for migration. The browser war is not effecting me much
marvinh.
marvinh.12mo ago
As much as I love firefox (use it as my main driver myself at home) I think it's easy to underestimate the effort required to go down that route. It's easy to say "just do XY", but we're talking about a significant amount of money here. Picking a JS engine that you're not familiar with, has way less backing then the one you are already familiar with, is a super risky bet when your building a company around it.
Ooker
OokerOP12mo ago
I'm not sure what you are referring at when you say "just do XY" and the engine that I'm not familiar with. Are both referring to firefox?
marvinh.
marvinh.12mo ago
you suggested that picking Firefox's engine for Deno would be a viable option my message refers to that
Ooker
OokerOP12mo ago
ah I see you mean Ryan also was not familiar with gecko?
marvinh.
marvinh.12mo ago
well Ryan created node, so he obviously was way more familiar with v8 compared to gecko
Ooker
OokerOP12mo ago
I see. Thanks for your time

Did you find this page helpful?