As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In Java world I always press F3 if I want to jump into a method or class, variable... anything really.
I am now working on a Javascript project and I am finding the F3 (Open Decleration) extremely limiting in Eclipse and in Aptana. Its actually almost non-existent, working only for declared variables in methods.
Our project has grown to about 50 Javascript files (~60 Javascript "objects"), and things are becoming almost unmanagable because of situations like this :
this.url = Util.buildURLFor(URLs.ticketPrefillData);
The Util object is in a file called Toolbox, and the URLs object is in a file called URLManager. The question is, how is anyone supposed to know that it is in the Toolbox file? And why can't the IDE pick out all the objects in all the files, so the F3 knows where to go.
As the javascript files grow it is becoming unmanageable (in an agile project this can be fatal) and we are thinking of switching back to Java in the form of Vaadin or ZK, unless we can find a decent intelligent IDE for code navigation.
In Summary, I need a JS IDE which can do this :
I have a method in file A which calls a method on class B1 which is in file B. It seems like no IDE i have come across can make that association.
Check out WebStorm by JetBrains. I haven't used it but have heard great things about it. It supports code navigation, and judging by ReSharper, JetBrains are really good at it.
Currently, I use Visual Studio 2012, which has great (enough, for me) navigation when you add references to your used javascript files. So in file A, when you use code in file B, you would just add this to the top of your file:
/// <reference path="./B.js" />
From now, you have Intellisense and code navigation. (VS2010 has similar features but isn't as powerful, if I recall correctly)
(your question is however kind of subjective, so might get closed/flagged; try to avoid asking questions where you ask people what they use/prefer; see the FAQ for more info)
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am creating an ajax powered webbased application. I am using jQuery and php. As a temporary solution when $.ajax success callback occurs I load the file.php into the page and on done I run a custom function initialize_js which looks for elements that I know need initialization and runs some javascript for those elements.
My current solution is similiar to this post
IMHO, this is going to get quite large and hard to manage. I know I could separate the js into it's own file and make a 2nd ajax call to load this content as a script but I felt this would have alot of overhead.
What do you recommend so that the code is organized and reusable. I hope to put my javascirpt_ajax routines into a reusable file for other projects on the site and these customized functions cannot be in there.
First of all, I recomand you to write your javascript code as OOP classes/functions. Google will help you with that.
Then since you said you will have pretty much code, is kinda mandatory to split the JS code in multiple files for multiple reasons: flexibility, maintenance, optimisation etc
In the end you should take a look at[ RequireJS. It helps you to load js files on the fly. So you load only the functions you need, when you need. Not all the files at the same time.
P.S. IF you want to be more rigorous and work like a pro then you might try an MVC library like BackboneJS, SpineJS, AngularJS etc.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm developing Desktop-Software with different OO-based languages. I haven't got in touch with web development since recently. I just started playing around with jQuery and jQuery Mobile to build simple web applications.
I noticed that my projects usually end up with a HTML-file as a base and a *.js file which contains the methods, eventhandlers etc. This somewhat feels like programming spaghetti code and I can't think of how this could work with more complex projects. (Reusability, Performance, ...)
Usual jQuery-Tutorials are just showing trivial examples which work well with the "all methods into a single script-file"-approach. I also read somewhere, that it is better to provide just a big file because it is faster to load just one file instead of a lot small files.
Can someone tell me how bigger jQuery-projects are structured and what the reasons for that are?
I'll try to break up your question into smaller parts:
"I noticed that my projects usually end up with a HTML-file as a base and a *.js file which contains the methods, eventhandlers etc. This somewhat feels like programming spaghetti code and I can't think of how this could work with more complex projects."
Sounds like your OO background has you spoiled. Javascript won't force you to use it's prototypal inheritance, and neither will jQuery. Nevertheless, it is there. Douglas Crockford wrote a piece about moving from a classical OO-centric inheritance to the prototypal equivalent: Prototypal Inheritance in Javascript
"Usual jQuery-Tutorials are just showing trivial examples which work well with the "all methods into a single script-file"-approach."
Yes, putting all your code in one file will work fine for a small website or web-app, but it doesn't scale.
However this is no difference from putting all your C method declarations in one header and all the code in one source file. My point being that you don't have too.
I'd recommend you look at a script loader like RequireJS as a solution to this problem. In worst case there's still nothing wrong with putting your script tags inline in your HTML code but this also doesn't scale well.
"I also read somewhere, that it is better to provide just a big file because it is faster to load just one file instead of a lot small files."
Well ... yes, but this is negligible in most cases. Even if you do see a drop in performance, why treat your development code as your production? Use a compression tool such as YUI Compressor to compress and merge your JavaScript. Smaller load times without the pollution.
Final piece of advice: jQuery is not going to help you solve your JavaScript architecture problems any more than a dictionary will help you structure a sentence. (In other words, don't rely on jQuery examples to teach you good JavaScript practices).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I occasionally write JavaScript code. I am interested in minifying it for better performance, but I don't plan to spend to much time on that, especially in testing the minified result.
I found this online service:
http://www.lotterypost.com/js-compress.aspx
So a couple questions:
Is it reliable?
Microsoft AJAX minifier vs. YUI Compressor, what's the best option?
Any other similar online tool to recommend (and why is it better than the above link)?
Google's Closure Compiler
is an excellent Javascript minifier and compiler. It analyzes the code and reports the detectable errors. It removes redundant space and unreferenced code, and renames objects to shortest possible names. You just need to compile together all Javascript files that belong to one HTML page.
That link you post happens to be the one that I use too.
Use the MS AJAX Minifer. It's way better than the yui one. besides:
http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx:
The Microsoft Ajax team (I work on
this team) has been using this tool
internally for a number of years. For
example, we use the Microsoft Ajax
Minifier to minify the Microsoft Ajax
Library before publishing it.
Well if you don't trust me, run your source code (if you don't have an actual source code to test, just grab the source at http://code.jquery.com/jquery-1.6.2.js) through both and see which is more "minified".
==
Google has the Google Closure Compiler but it analyzes your code and removes unreferenced code (to furthur reduce the size of the resultant file). However usually this is not what you want because even though the functions/variables are not referenced within that file, it may be referenced from your other js files that make up your site)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
Being a C# developer, I cannot grasp why in the world one would spend time designing a perfect class in javascript, when you can't get any editor today with intellisense that will fully show you your class rules. There is only one way to maintain a well designed class in JS by documenting everything, and requiring a developer that uses the class to always refer back to its documentation.
For me - trying to become a professional javascript developer - it's so frustrating, I feel so unproductive. why is that? why can't we get an editor that will work just like C#. or maybe we would be better off if browsers starts to support a normal OOP language?
Visual Studio works quite well considering the fact that Javascript is a very dynamic language where certain functionality/fields can be added removed from an object at any moment. And Javascript isn't really OOP in a sense you know in C#. It's prototyped which is different.
Think of such an engine and you'll see that Visual Studio is doing quite well with its Javascript intellisense support.
How to enable intellisense in certain file
You have to reference other javascript files in yours to get intellisense for their functionality of course...
/// <reference path="jquery-1.4.1-vsdoc.js" />
Paths are relative to your file. This will make it possible to get intellisense for jQuery in any of your files that will have this directive right at the top of the file. References must be used to actually enable particular file's intellisense. This makes sense of course since you can have multi-faceted functions defined in various files and only one of them is used per page. Each using a different one.
Your plugins and VS JS Intellisense documentation
And when you want your code to be reused you can always add XML documentation to your code file and others will get intellisense as well while using your Javascript code file. If you don't know how to do this check the plugin on this blog post of mine and check the .toDictionary() function that has the documentation that Visual Studio is able to use for intellisense purposes.
The OOP design around javascript is more for creating a clean, maintainable, code base. You'll have seams you can use to write QUnit tests for. You can easily identify errors and rewrite code without fear of breaking stuff. You can create namespaces and closures as well. OOP is not about code completion is more about a way to write your code and not have your code written for you ;)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
can anyone please help me to identify the best AJAX development IDE or tools base on the advantages and disadvantages? Thank you
I like too much Aptana Studio.
For the "tools" part of your question, I have found the following combo quite good:
Firefox + Firebug + FireQuery + FireRainbow + PageSpeed + Web Developer
Have a look at the up-coming WebStorm from Jetbrains.
Upsides:
Support for Javascript and extended frameworks, such as YUI, JQuery, Dojo and Prototype; code completion, refactoring and code inspection. Mozilla-based Javascript debugger
From the help file:
Smart, DOM-based, browser-type aware JavaScript code completion for:
Keywords, labels, variables, parameters and functions.
User defined and built-in JavaScript functions.
JavaScript namespaces.
JavaScript and AJAX error and syntax highlighting.
JavaScript and AJAX-aware refactorings:
Rename a file, function, variable, parameter, or label (both directly and via references).
Move/Copy a file.
Safe Delete a file.
Extract inlined script from HTML to a JS file.
Extract function.
Numerous JavaScript and AJAX-aware code inspections and quick-fixes.
JavaScript and AJAX Intention Actions that let create various application elements.
JavaScript and AJAX code formatting and folding.
JavaScript and AJAX code blocks, live
Downside:
Not free and not yet released (there's a 45 day trial on the Jetbrains website)