1

What is the industry standard or professional process of finding out where the actual line number in the source code of your rendered page is happening?

I have used browser debug tools and it of course shows you the error, but the line number is not the same for the source code file that is being served up. I know that usually server side scripts are making the file longer than it really is and etc.

I usually just do a find for functions or code near the error and can eventually find it, but is there a better way?

2
  • If the server is modifying the script before serving it, look into generating a source map which the browser can understand. That should allow you to translate line numbers. Commented Oct 10, 2014 at 20:22
  • When a console error is generated in Chrome, there is a link at the righthand side of the console window (one per row of output) which shows the file and line number where the error was generated. These line numbers values are not very helpful in your case -- but you can click the link and get taken to the script code within DevTools. I find this behavior to be very helpful. Commented Oct 10, 2014 at 20:26

2 Answers 2

1

The simplest way is to ensure that most of your JS is written in non-templated .js files, rather than inline <script> blocks in your templated html.

Sign up to request clarification or add additional context in comments.

1 Comment

When I read this I said to my self "Duh." This makes the most sense to me, and I can understand this in regards to the level I am at. I am still learning a lot about the developer tools, but it has saved my butt a lot. I am taken back by how often people including my self don't use them, and are lost.
0

I develop with Visual Studio.net 2013, which will stop at breakpoints and break on server and client side errors. If you aren't developing with a tool like VisualStudio that has a built in debugger with breakpoints, etc., the built in developer tools in Chrome and IE are awesome (IMHO). Since Javascript runs clientside, you'll need to debug it using the browser. If you don't like the built in developer tools, you can also try Fiddler and Firebug.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.