I am using the version of htmlunit 2.56.0.
As soon as JavaScript is executed in Java, the CPU is increasing a lot.
So I want to check the Rhino JavaScript engine version. How can I find it?
Or let me know if you know how to lower the CPU.
Thanks developers!!!
HtmlUnit uses a customized version of Rhino - you can find the repo here: https://github.com/HtmlUnit/htmlunit-core-js.
As HtmlUnit provides a bunch of patches to rhino the code is in sync with the latest code from the repo.
There are some issues open regarding js code (usually some obfuscated stuff) that shows this effect. If the url of the page is public please open an issue on github and i will try to have a look.
Even better if you can profile this or nail down the problem we are usually able to fix it or make improve Rhino itself to get this working.
Related
Recent versions of IntelliJ have an "IDE scripting console" option under the tools menu. I've had a hard time finding blog posts about it.
Some of these posts pointed out, and the gui proves this, that it has support for javascript.
Could someone please point me to an example or blogpost how to use this feature (api docs) with javascript please?
Here is how to use it: https://www.jetbrains.com/help/idea/ide-scripting-console.html
Here is the API docs: http://www.jetbrains.org/intellij/sdk/docs/welcome.html
Best/largest(?) set of examples I could find: https://gist.github.com/gregsh/b7ef2e4ebbc4c4c11ee9
Unfortunately for JS there is the least amount of examples.
That said, I've tried to implement an Action that starts the first Run Configuration. The code actually works pretty well. I've got stuck, however, on how to extend the Java Action abstract class from JS. Below is the working code:
var result = function run() {
var executor = com.intellij.execution.executors.DefaultDebugExecutor.getDebugExecutorInstance();
var runConfigsSettings = com.intellij.execution.RunManager.getInstance(IDE.project).allSettings;
var a = com.intellij.execution.ProgramRunnerUtil.executeConfiguration(IDE.project, runConfigsSettings[0], executor);
return a;
}()
I found the necessary docs here:
http://www.jetbrains.org/intellij/sdk/docs/basics/run_configurations/run_configuration_execution.html#starting-a-run-configuration-from-code
Hope this could help anyone.
Write in the comments if you know how to create an Action in JS.
IDE scripting console for JavaScript requires NodeJS installed on your computer (and make sure it's available on you PATH system variable for Windows OS, whereas for Mac OS you just need to install it with brew).
Main reason why it may not work is NodeJS installation missing/misconfigured, or due to IntelliJ being unable to get an access to NodeJS binaries (the latter is mainly Windows specific problem).
Once you have NodeJS up & running, simply write any JS code as if you did it in regular JS file, and press F10 (or control + enter in some configurations) in order to run the script
NOTE: I use fully licensed IntelliJ Ultimate 2017.x, all the above is for this particular version, I haven't used the community edition for a while, therefore I doubt I'll be able to help you with that one
I looking for python/JavaScript IDE where I can put breakpoints. Currently I'm using coderunner but I can not put break points. I'll really appreciate you recommendations
I'm not an expert on Python, but I do work as a web developer and use JavaScript regularly. For that side of things, probably the easiest way is to use Chrome/Firefox debugger tools. You can do this manually by finding the line of code in the console and clicking (F12->Sources tab->Content scripts->desired script), or using the 'debugger' statement to toggle debug mode (F12->Console tab->type 'debugger' then return) and step through to what you need.
Additionally, if you're looking for an actual IDE, the only thing I've found online is the following. Here's the relevant part of that article. I've never used it (and probably never will), but there it is all the same.
Webstorm by IDEA supports setting breakpoints in the IDE. This requires launching the JavaScript debugger from IDEA. It must be configured in advance so it understands how to map JavaScript on the development server to JavaScript files in your environment. IDEA will automatically install a Chrome or Firefox plug-in to facilitate. This is pretty new technology and can be touchy.
I use PyCharm. It's a heavyweight IDE, so expect more features than you probably want if you're just getting started. It has a very good integrated debugger. You'll be able to break into both your Python and Javascript. Further, you'll see a pretty nice productivity jump with all the editing support like auto complete and intellisense. My advice is to stick with print() and logging as long as you can. For me getting a firm grasp of packages, python environments, virtualenv, command line tricks and git all before committing to the PyCharm IDE helped me adopt it with more confidence I was getting the value of all the integration.
I'm trying to debug some Javascript code inside a JSP page in a web app (Servlets, JSP and JavaScript) I'm working on. In order to be able to debug it I understand I need to check the Debug Web Application (Client side JavaScript) option under Debug section in the Project Properties window.
The problem is I don't have any Debug section in the Project Properties window. I also don't have the JavaScript Libraries section, but I'm not sure whether it's related or not.
What I'm looking for is what is shown here.
Just to be clear, what I need is to be able to debug JavaScript, so if there's a different solution for doing this I would be more than happy to here about it.
If its worth anything I can put breakpoints inside JavaScript, its just that I cannot see any values of variables.
Thanks,
Alon
[EDIT:] As ladar kindly pointed out, the JavaScript debugger was dropped from Netbeans in previous versions (It seems like in version 6.9). As an alternative I use Firebug now.
What version of NetBeans are you using? Javascript debugger was dropped in recent versions (as far as I know 7.0 and newer doesn't support it). So because there is no js debugger, this screenshot is not there because it will always debug server side code
Just as we have http://www.sliver.com/dotnet/SnippetCompiler/ (link inactive on 2021-04-24) to test a C# code quickly, I can also do the same for javascript in chrome debugger tools and Firebug (firefox).
I would be more interested in a tool or some online tool which can run a small piece of javascript and tell if it properly runs in prominent browsers and the result.
UPDATE:
I'm a developer and not tester. I don't want to install all browsers on my PC. I like chrome and I can debug/test (for syntax/result) almost every javascript quickly in chrome by just clicking Ctrl+Shift+J and pasting my javascript in its console. But that will just test if it works in chrome. I'm not interested in creating a library right now. Google and Stackoverflow helps me get the greatest and latest javascript for a specific task very quickly.
I found one way. But it is not that quick and still would like to know better answer. May be some kind of tool which can do this.
One Way:-
Write your javascript enclosed in try-catch block on JsBin and create its public link. Now check your link with BrowserShots.
Write considerable amount of html (conditionally) using javascript to be able to see the difference on Images given by BrowserShots.
To propose another option 10 years down the line: I would suggest using JSHint for this.
The first page as you navigate to their site allows you to simply paste a JS snippet and get information regarding everything from potentially confusing syntax to "minimum ES version" warnings.
Furthermore, you can also install JSHint to your project and have a command to either run manually or slot into your existing build chain to do the same thing locally with custom rules.
I've also found this tool: JS Compatibility Checker, which is based on Can I use.
Could be helpful, but won't outline every issue.
You can easily make a test page to house your snippets, then try them in your target browsers. That has the added advantage of providing a central library for the snippets you do create, so you don't have to go hunting through entire directories looking for that cool little widget you created back in 2010.
Also, you can check the MDN Web Docs Browser Compatibility section if that interface is available (Eg. window.location - https://developer.mozilla.org/en-US/docs/Web/API/Location#browser_compatibility)
I think that Visual Studio's biggest let down is the Javascript editor. I have been told to use Aptana as an editor for my javascript files, but I would prefer to stick with visual studio if possible.
I have read other similar plugin posts, but none focus specifically on Javascript.
VS2010 may offer some improvements, but will they be up to Apatana standards? I have briefly tested the beta, but I'm not overly impressed.
Is there anything out there that will bring Javascript closer to c# development? Considering the wide spread use of Javascript I think there must be something....... I hope! :)
Many thanks in advance... this is something that has always bugged me!
There's a couple recent plugins that may be helpful :
From Microsoft :
JScript Editor Extensions
Brace Matching
Outlining / Cold-folding
Current Word Highlighting
IntelliSense Doc-Comments Support
JSEnhancements
Outlining and matching braces highlighting
(I wouldn't think installing both of these is a good idea - and the Microsoft plugin has more features so try that one first)
VS is a pretty good IDE (especially when coupled with Resharper) but not so hot with Javascript. The debugger is good and there's the JSLint plugin but other than that I'm not sure. Aptana (based on Eclipse) is an excellent javascript IDE but it doesn't like it much when the javascript is embedded in aspx files (unless they updated the support recently). So far I'm not sure there's an ideal .net platform IDE for both client and server side stuff just yet.
Update: Resharper 6 added pretty good JavaScript support - so now I'd recommend that combination if you're doing a lot of debugging across client and server at the same time. If you're focussing on pure client code then I find WebStorm to be an excellent JavaScript/HTML IDE - even better than Aptana.
I'd really like to recommend Webstorm. It does not! treat your JS as text files.
Its a full blown JS editor and has become my favourite JS editor working in parallel with VS to handle my server side stuff.
WS has actual object intellisense across JS files. That means when I press . (dot) it shows me the functions on that objects, even if its located physically in another file.
It will recognize my objects (or their type if you will) created in other JS files referred to in the file I'm working on.
I have 'Find usages' on JS functions
I have 'find all references' on JS object / function / class / variable or whatever you want to search on. In the end its all objects but Webstorm knows this.
If I change the short/cut to F12, I can press F12 on my function call and it will jump to the implementation of that JS functon. Even if its located in another file.
Ofc. you have code folding and colouring, extract method and other neat code re factoring, overview creating tools.
Oh. And by the way.
I'd like to kill off a rumour going around in the cloud on forums I come across from time to time, looking for better ways to handle JS.
reSharper DO NOT SUPPORT JAVASCRIPT! A little piece of me dies every time I read some guy repeating what he saw on the reSharper site. It may have a some poor intellisense and some low level syntax check, but that has nothing to do with support.
Notepad++ supports JS better than VS in my opinion.
Münster
Don't forget to grab Chirpy to handle minifying your scripts in VS.
If you use Visual Studio, add the
/// <reference path="myOtherJsFile.js" />
directive at top of your js files and install Web Essentials you get pretty decent (but not perfect) intellisense, go to definition by using F12 and find all references (sort of..) by using SHIFT+F12