Chrome Dev Tools & Inline Dynamic JavaScript

If you are using Chrome dev tools to debug your application then you might have come across this situation.  If you dynamically load some content, and that content contains an inline <script> tag, then annoyingly you can’t see that script under Source in the developer console.

Thankfully there’s a nice simple solution to the problem: insert the following tag at the end of your inline script:

    //@ sourceURL=MyInlineScript.js

This will make the script appear in the Sources list under the “No Domain” section:


Remember that if the inline script is part of a Razor view then you will need to escape the @

    //@@ sourceURL=MyInlineScript.js


Since this post was first written the syntax has been changed to use //#

    //# sourceURL=MyInlineScript.js

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s