Debugging JS production code

bfuchs
bfuchs used Ask the Experts™
on
Hi Experts,

Two questions...

1- Is there a way to temporary change the JavaScript code of a production site for testing without affecting the site itself by other users?
2- I have a link that when double clicking on that it keeps spinning, but when I copy/paste the URL in the navigation pane it works, how can I troubleshoot that?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

using chrome right-click inspect and check into the console for error.
if you change the code it will have consequence for all users except if you load script per user role so let say you have debug user role and only run some script for this user this won't affect other user .
This will require some server side code to check the user role and load the JS script for only that user.
If you don't have session & role then you will need to duplicate the page mypage_temp.html and do you tests on this page only.
@lenamtl,
using chrome right-click inspect and check into the console for error.
Are you referring to #2?
If yes, the problem is that I cannot click on anything as everything keeps flashing including the debug window.
if you change the code it will have consequence for all users...
I had a consultant that claims he was able to test some test code he wrote against my production site, wondering how is that possible...?
Thanks,
Ben
Yes, so using chrome inspect you can see if there are errors into the console.
This help to find what is the related code and which file and line of code that have error, plus the type of error.
You can also run code from the console.
When developing we often console.log the result this is a way to display the values.

Note using the console, if you edit the code let's say you run a script or change a color it won't be saved and it will be done only on your browser for tests / debug purpose.
As soon as you relod the page you will loose the changes into the console.

It is a good idea to keep the console open during the tests

Note if this is flashing, right click / inspect then go to source tab and click on Pause script execution.
This is located at the right of the console
That will stop / pause the Javascript script

Most of browser have a console and code may work ok in some browser version and not from other version.
It is a good idea to know the browser name and version when you have an issue so you can try to reproduce the error in other browsers and /or  version.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

@lenamtl,
Note if this is flashing, right click / inspect then go to source tab and click on Pause script execution.
Did that but dont see anything wrong with the code.

Perhaps you can suggest a way to record my screen so you have an idea whats going on here (e/t keeps jumping, difficult to explain...)?

Thanks,
Ben
Hi, when you pause the script does it stop the jump / flash effect?
There is no error into the console tab?

do this test go to the page right click inspect  / check into console tab (without pausing the script) is there any errors?

Do you have live link so I can check?
Hi lenamtl,
I have been trying yesterday and today to reproduce this issue and couldn't.
Lets wait another day or two till this happens again, will send you a link.
Thanks,
Ben
leakim971Multitechnician
Top Expert 2014
Commented:
I had a consultant that claims he was able to test some test code he wrote against my production site, wondering how is that possible...?

check in the debugger console, we can change all links background color on expert-exchange :
red
Hi,

check in the debugger console, we can change all links background color
Right, but that is only for style and color, what about changing embedded JS code?

Thanks,
Ben
leakim971Multitechnician
Top Expert 2014

Commented:
Right, but that is only for style and color, what about changing embedded JS code?

we don't change anything

he was able to test some test code

we run/test new code
leakim971Multitechnician
Top Expert 2014

Commented:
A good episode for global learning  : https://www.youtube.com/watch?v=H0XScE08hy8

If your really want to test your code on your prod website you can use :
https://developers.google.com/web/tools/chrome-devtools/workspaces
check the first 2min here too : https://www.youtube.com/watch?v=D1pV7ermy6w
Hi,
When using the dev tool to check errors you need to select Console tab not the Sources Tab.
It's look like you have a kind of loop, or something refresh / reload the page rapidly.
Thanks Experts!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial