Easiest way to find and correct javascript error?

Relax and enjoy The Lounge. For all Non-Joomla! topics or ones that don't fit anywhere else. Normal forum rules apply.
Locked
the apprentice
Joomla! Guru
Joomla! Guru
Posts: 801
Joined: Wed Nov 18, 2009 3:53 pm

Easiest way to find and correct javascript error?

Post by the apprentice » Sat Dec 26, 2020 8:18 am

I'm being told that my website has a javascript error, I tried with web developer but not sure how to use it, any suggestion on how to fix, or try to fix, this before asking for professional help or something. Thanks.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17321
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Easiest way to find and correct javascript error?

Post by toivo » Sat Dec 26, 2020 9:20 am

Were you told what the javascript error is and where is it? Sometimes those errors are just conflicts between functions in two different javascript libraries.

Load Web Developer Tools by pressing F12 and go to the tab Console. That tab shows avascript errors in red and which script they are reported from.
Toivo Talikka, Global Moderator

the apprentice
Joomla! Guru
Joomla! Guru
Posts: 801
Joined: Wed Nov 18, 2009 3:53 pm

Re: Easiest way to find and correct javascript error?

Post by the apprentice » Sat Dec 26, 2020 11:41 am

I've tried with the web developer but can't make heads or tails of it, is that considered the easiest way?

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17321
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Easiest way to find and correct javascript error?

Post by toivo » Sat Dec 26, 2020 12:23 pm

Take a screenshot of the problem page to show how far you get and our volunteers should be able to assist.

Web Developer Tools or DevTools is indeed the easiest way to find out if a web page has javascript errors. It is recommended by hosting companies and web developers, for example:
How Do I Diagnose JavaScript Errors on My Site?
How To Diagnose Site for JavaScript Errors
Toivo Talikka, Global Moderator

waterloospan
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Feb 01, 2021 4:15 pm

Re: Easiest way to find and correct javascript error?

Post by waterloospan » Mon Feb 01, 2021 4:26 pm

the web developer tool is a good starting point, you need to monitor what's printed out in the console, for simple problems it can give you the line where the code is throwing out the error. But if the error is thrown from nested or dependent code and even worse when they are minified JavaScript then it's harder to decipher that. In those cases you need some one with experience to inject some testing logic to locate the root problem.


Locked

Return to “The Lounge”