How to find which ASPX files actually reference JavaScript file? - javascript

Our ASP.Net project includes date.js (http://www.datejs.com/) in all of the .ASPX pages.
This script, however, throws exceptions during debugging even if page doesn't explicitly use it. So in all newly created .ASPX pages I don't include it unless it is actually needed.
Is there a way to find out what .ASPX pages actually reference functions from that .JS file (as opposed to just including this file)? For C# files I could just remove file from the project and see if there are any build errors. Is there a similar approach for .JS files?
I am looking for an approach that doesn't require having to browse to each and every page on the site.

Try using Firefox firebugger. Go to its script tab locate the code related to date.js and set a debug breakpoint, now try surfing around your site and you will see which pages are using it.

Related

How to render openFrameworks app to host on browser

I'm new to both openFrameworks and this compiler called Emscripten.
After struggling for a few days, I was able to compile my openFrameworks/C++ code into js but Emscripten gives me an html file with a lot of junk included (For example, there is a header and footer -
http://openframeworks.cc/setup/emscripten/)
I'm trying to host the video/animation itself like it is on this page (http://www.syedrezaali.com/#/great-scott/) but I have no idea how to go about it. Can anyone help me out?
Thank you
If you follow OF's guidelines Emscripten generates not only the html file but also some other files (I think it's 4 files in total). You need to copy all of those into your site, then link to the html file.
Notice that while developing you can use
emrun --browser chrome bin/yourSample.html
To open the file, but you cannot just open the .html file (not sure why). See this guidelines as well, which are linked in the OF tutorial.
Update
I haven't tested this, but it looks like OF loads a site template. See this makefile for emscripten, you may specify your own via PROJECT_EMSCRIPTEN_TEMPLATE or you could just change the template OF uses.

Expose compiled Julius templates as a seperate file, instead of directly placing them in the DOM

When debugging JS, Chrome allows you edit JS and then reload the page. This can only happen if the JS you are editing is provided as a separate resource. As far as I can tell, it's currently not possible to debug JS code is this fashion because of the way Yesod drops any included JS on to the page directly.
Editing a julius template file without changing any variable interpolation allows for instant reloading of the page. However, if I include small snippets of javascript with:
toWidget [julius|doStuff();|]
I can't edit this Javascript for debugging without causing a reload of the model, which for our case, takes ~1minute. Is there a way around this?
There are multiple choices here:
If you put the Julius content in an external file, you can use juliusFileReload and then edit the file and reload the webpage without a recompile. The scaffolded site does this by default.
Have generated Javascript be placed in a separate file. This is also the default behavior of the scaffolded site.

How to reference a TypeScript file from a web page

Preamble
I can get this to work but I'm not sure I'm using the technology as Microsoft intended.
Context
A web page can refer to a JS file containing JavaScript by means of a reference tag like this:
<script src="Scripts/jquery.js"></script>
In the above example, the JS file is part of a Visual Studio ASPX.NET project. It was both placed in the project Scripts folder and added to the project by Nuget.
Having added a Typescript file to an existing ASP.NET project, I would like to use the generated JS from an ASPX web page.
Instructing Solution Explorer to show all files reveals that the expected JS file has indeed been generated on the expected path.
Am I using this correctly? What is the recommended method?
There are a couple of ways one might go about things.
Refer directly to the generated JS file
I was concerned that files not part of a project would be excluded from a web server deployment, but have since determined that they are deployed.
Add some kind of reference to the Typescript file
It would be great if there were some syntax for a reference to the TS file that will be transformed into a script tag referring to the generated JS file. Alas, if this exists it's not very well publicised.
In VS2015, dragging the TS file onto an HTML or ASPX page in the editor will insert a link tag referring to the corresponding JS file.
DO NOT use server URL rewriting to remap references to the TS file to the JS file. This interferes with VS and browser debug support via source map files.

Tool to identify which external javascript references are actually being used on a page

I'm working on a website that currently has the same block of external JavaScript references on each page (added via a master page). I'd like to go through the site and identify which script files are actually necessary for each specific page to improve performance. Problem is there are a lot of pages and I'm not sure how to do it without resorting to manual trial and error process.
Is there a Firefox plug-in or some other tool that will identify which JavaScript references could actually be called by the page and which are not necessary?
you can use firebug plus his plugin for javascript code coverage: http://getfirebug.com/extensions/index.html#firebugcodecoverage

Referencing Javascript libraries with Tomcat

I am using Eclipse Ganymede and Tomcat 5.5. I would like to add some javascript and especially ajax functionality to a dynamic web project and need some help.
I would like to use jquery (but I am open to other suggestions, if you tell me why another library would be better in this case, but I have chosen jquery because it is supposed to be simple (which on the first look it seems to be)).
I am having two problems:
1- Tomcat can't find the jquery library. I tried several things in my jsp file like:
<script type="text/javascript" src="WEB-INF/lib/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/WEB-INF/lib/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="./WEB-INF/lib/jquery-1.3.2.min.js"></script>
As you can see, I threw the jquery library in /WEB-INF/lib. Executing the jsp file within a browser without tomcat (with the last path version) works, so the path is correct.
2- There is no proper syntax highlighting within the dynamic web project for jquery and no popup suggestions. I also tried the information in this article, but it didn't change much.
To be more specific (because it took me about half an hour to figure this out after getting to this point):
When you create a Dynamic Web Project with Tomcat in Eclipse, among other things in the project you get a folder named "WebContent". That's the actual folder that gets deployed to the Tomcat server, in Eclipse's equivalent of Tomcat/webapps/<project name> (I'm not sure where it really exists). For security reasons, as a special case nobody can access the META-INF and WEB-INF folders in there, so putting your scripts in those places will not help.
What you have to do is create a folder inside of WebContent, and stick your Javascript in there. This folder will be globally visible, so visitors to your site (like you, when you test it) can actually get to the Javascript.
What I did, for instance, was create a folder named "script" in WebContent and put my Javascript in there; then, when I needed to reference it in a page, I put in src="ProjectName/script/AwesomesauceJavascript.js"
I'd like to add to what #Tacroy responded with. Within the server you're using in Eclipse, check the server.xml. Make sure:
Context docBase="SomeProjectName" path="/SomeProjectName" <-- path and docBase attributes need to be the same.
I had two different things there, and had to make them identical for the src attribute to work in the jsp.
First you must to add resource mapping to your folder where you put jquery.js script library. That folder must be public.
To make folder public use this line of code:
<resources mapping="/scripts/**" location="/WEB-INF/scripts/**" />
Now you just need to add reference in your page to this path:
<script type="text/javascript" src="scripts/jquery-1.10.2.js" ></script>
Below are the steps to enable jQuery syntax highlighting and content assist highlighting in Eclipse.
Download jqueryWTP0.40foEn.jar.
Find your Eclipse Plugin org.eclipse.wst.jsdt.core_version.jar, backup the plugin.
(e.g. C:\DEV\EclipseIndigo37\eclipse\plugins
\org.eclipse.wst.jsdt.core_1.1.100.v201104272153.jar)
Double click the JAR file or run with command java -jar jqueryWTP0.40foEn.jar.
On the opened swing UI, choose org.eclipse.wst.jsdt.core_version.jar, and output directory.
Click the generate button.
Replace the old org.eclipse.wst.jsdt.core_version.jar file with the generated file.
Delete the directory workspace/.metadata/.plugins/org.eclipse.wst.jsdt.core
Start Eclipse.
Open a HTML file or a JavaScript file, edit JavaScript content.
jQuery content assist is now available.
Plugin Developer & Source

Categories