Reputation: 2969
I have a script tag that is being loaded as a data uri, ie
<script type="text/javascript" src=[some data uri]></script>
I would like to be able to define something regarding my script such that when an error occurs on my page, rather than that error appearing in the console with a crazy data uri as the file name, it appears with a file name that I define.
Ideally the correct file name would also appear when you console.log.
Is this possible? Thanks!
Upvotes: 2
Views: 227
Reputation: 2969
Turns out that you can do this in webkit with the //@ sourceURL directive at the bottom of your js code.
This even works in evaled code!
Pretty sweet: http://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/
You can do a lot more with sourceMaps and there is support from other browsers, see here: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-howwork
Upvotes: 2