Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to throttle javascript performance to simulate a slow client

Tags:

javascript

I am working on a site that uses jQuery and has a fair amount of javascript that is run using $(document).ready(). On my dev machine everything runs great but it's a pretty powerful machine. I have had reports from people using older hardware of behavior that seems strange and I am fairly convinced that it is down to the time taken to process this initial javascript on slower machines.

Clearly, the solution is to sort out this initial javascript but it got me wondering - does anyone know of a way to slow down the execution speed of javascript in either Chrome or Firefox to be able to simulate these slower clients on my dev machine?

Cheers!

Update: Back when this question was posted, there weren't the same set of tools that there are today. At that time the VM option was the best option therefore I am leaving it as the accepted answer. However these days I would go straight for Chrome dev tools instead as suggested by Oded Niv

like image 519
Addsy Avatar asked Dec 15 '11 14:12

Addsy


People also ask

How do I simulate a slow CPU?

Go to Power Options -> Create a power plan -> Change advanced power settings and set CPU Maximum Rate to 5% or how much you need. This usually helps test browser apps on slower configs. Save this answer.


3 Answers

Under Chrome developer tools -> Timeline you now an option to throttle down the CPU, look for the dropdown:

Chrome CPU throttling

UPDATE:

Chrome(ium) changed in new versions, it is now under the Performance tab, and you have to click the settings button in the corner for this feature to show up:

Chrome new CPU throttling

like image 112
Oded Niv Avatar answered Sep 19 '22 06:09

Oded Niv


This might not be the best solution, but something that could definetely work is to run a virtual machine, there you could specify all hardware specs as long as they are lower than you real machine. Look at this post

like image 28
isJustMe Avatar answered Sep 21 '22 06:09

isJustMe


I would use a VM and just limit it's resources. If you are not a fan of virtual machines, then I would go find an old machine at a yard sale, thrift store etc. and use that as a testing platform. You can never patch it, fill it up with crappy malware laden programs and then it will be just like the experience for an "average user." :-)

like image 44
gavaletz Avatar answered Sep 22 '22 06:09

gavaletz