Using for loop in javascript for 50k time without hanging of browser [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have to run a loop for 50,000 times, but it is hanging browser. what could be the best way to do it.
sample :
for(var i=0;i<50000;i++)
{
// Here I am calculating 50 different values.
}
I can't use php because values are displayed directly in html page.
what I can do for it?
thanks

You could try a webworker. Here is a package that might simplify things for you.

Related

What's the most optimal code to run a code every month on a node server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
I have a credits score on my app, I need to update the database every 30 days how can I do this? sometimes the server crashes because of errors and restarting the instance and I assume the function would not run anymore, is there any other possibility to make sure users get their records updated? Thanks

Real time website information/content updating [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Since a year and a half I am trying to figure out how some websites update their content in real time without AJAX method.
Please see this example website: https://pro.btcturk.com/en/basic/exchange/BTC_TRY
That website is changing many texts within content in different timing.
It means that when the server is updated with new values in the database then the website is listening to database changes and then reflecting/delivering inside content without ajax calls.
Can someone give an example how to achieve such functionality possibly using Javascript or PHP normal hand-code appreciated?
Thank you
You can see the process here:
More information here: Websockets

Why my browser not able to run updated code? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am changing my javascript code but browser somehow using old code which i deleted, somehow caching old code. Why is it happening suddenly? And how to prevent it?
Use Ctr+Shift+R for every run.

Javascript, how do I make it loop this? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
So I wish to loop the javascript going to a certain page (without actually reloading/clearing console), then execute
href="javascript:doSomething(9)"
and then loop that by doing a function
Please help, thanks!
Assuming you want it to repeat - you can use an interval.
setInterval(function(){
doSomething(9);
},100); // the 100 is for 100 miliseconds
If you want it to repeat without having to wait (that is, block the code) you can use a normal while loop:
while(true){ // will loop forever since the condition is always "true"
doSomething(9);
}

Is it possible to block end users from using Javascript to trigger events? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
As an example, let's assume I want to prevent users from using auto-clickers. Is it possible, and are there accepted best practices when doing this?
Nope, it is not possible. Someone can always turn off JavaScript, modify it, run their own JS-code, etc, etc. JavaScript should never ever be used for security reasons.
However, for AJAX-requests you could implement a minimum interval server-side (like on Stack Overflow).

Categories