Reliable and convenient JavaScript minifier [closed] - javascript

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)

Related

What is an organized way to run js on content load? [closed]

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.

Is there an IDE that can do intelligent navigation through Javascript? [closed]

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)

Javascript, Intellisense and compiler notification [closed]

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 ;)

Complex js obfuscator [closed]

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 need a complex js obfuscator so that the js file won't be easy to reverse with a public tool like http://jsbeautifier.org/
You may try jscrambler.com. It's the only one I know that could help you. Check what it does.
You can shrink variable names when you use Dean Edward's packer. While this can be reversed, it does leave you with pretty unreadable code as the variables aren't easily identifiable.
http://dean.edwards.name/packer/
Use Packer algo http://dean.edwards.name/packer/
do check the options 'Base62 encode' and 'shrink variables'. This will obfuscate the code to a certain limit but still, as #musicfreak said, anyone who is determined can still make out the code.
If you use a JavaScript library, consider Dojo Toolkit which is compatible (after minor modifications) with the Closure Compiler's Advanced mode compilation.
http://dojo-toolkit.33424.n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t
Code compiled with Closure Advanced mode is almost impossible to reverse-engineer, even passing through a beautifier, as the entire code base (includinhg the library) is obfuscated. It is also 25% small on average.
JavaScript code that is merely minified (YUI Compressor, Uglify etc.) is easy to reverse-engineer after passing through a beautifier.
Google Closure Compiler.
http://code.google.com/closure/compiler/
I use it on advanced. Read the docs about exporting public methods etc.
http://code.google.com/closure/compiler/docs/api-tutorial3.html
It rocks.

What are the best AJAX development tools? [closed]

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)

Categories