What’s hot in JavaScript today

What’s really hot in JavaScript these days? Glad you asked. Okay, I asked.

Bower

A package manager for the web, created at Twitter. Bower has helped me managed by JavaScript libraries better. One good side effect that came out of it is that it kinda prevents developers from altering the libraries. Remember those times where you upgrade a library and then realized your library is somehow a custom build version? This get detected much earlier because each we check out code from the SVN repository we also do a fresh install of components in bower_components.

More information at Bower.io.

Modernizr

Taking advantage of cool new web technologies is great fun, until you have to support browsers that lag behind. Modernizr makes it easy for you to write conditional JavaScript and CSS to handle each situation, whether a browser supports a feature or not.

More information at Modernizr.

D3.js

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.

More information at D3.

jQuery

jQuery isn’t new but it still is really popular. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

More information at jQuery.

Mocha

Mocha is a feature-rich JavaScript test framework running on node and the browser, making asynchronous testing simple and fun. Mocha is easily my test suite of choice. I’ll write more about Mocha is there’s more interest.

More information at jQuery.

Lodash

Lodash is a drop-in replacement for Underscore.js, from the devs behind jsPerf.com, that delivers performance improvements, bug fixes, and additional features. It adds some additional functions too. Their collection tools are more comprehensive than Underscore.js’s. Currently it is at version 1.3.1.

More information at Lodash.

Angular.js

Something is really paradigm shifting is Angular.js. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop. However I find it hard to integrate this into existing work. It’s probably great for new projects though! I use Backbone.js and Marionette combination for most of my JavaScript works.

More information at Angular.

Django 2.0 released?

A company, Vyper Logix Corp, has released Django 2.0 without the blessings of the Django Software Foundation. According to James Bennett, the software is built on the Django 0.96.2 codebase which includes a critical bug.

Who would have thought opensource projects could be ripped off that blatantly. Django is a registered trademark of the Django Software Foundation, perhaps a warning could be issued. There’s really no point wasting time and resources pursuing this incident.

The man behind Django 2.0 is Ray Horn whose public LinkedIn profile can be viewed here. He owns a patent, a Python blog where he blogs as “Guido Python” and wrote some dubious Python software. (Guido van Rossum, by the way, is the Python’s Benevolent Dictator For Life.)

In the LinkedIn profile, he claims to be:

  1. Supporting around over 2 million lines of Python codes.
  2. And I quote “Accomplished, seasoned Consultant with over 30+ years experience in web based software using ColdFusion and JavaScript/AJAX; consultation work includes SBC/AT&T, IBM, Stanford University, NationsBank, and Multimedia Live.”
  3. And I further quote “Recently produced 6000 lines of JavaScript code in less than 3 weeks; 3200 lines comprised a reusable JavaScript based AJAX Framework.”

Wow I didn’t know there’s AJAX back 30 years. Didn’t know ColdFusion existed too. Erm, did the web even exist 30 years ago? The JavaScript code… I hope he didn’t release it as JQuery 2.0.

It appears it is not the first time, he did something like this. He has been criticized for taking BlogCFC, rebranding and releasing it for profit.

I am unsure if he did anything wrong here. He probably didn’t as the license might have allowed him to alter the software for commercial purposes so it is attributed back to the author. (I am not expert in software licenses.) But what he did here violates commonsense software ethics because there weren’t significant change from the opensource version. It just start to get me thinking – how to stop such activities. At the end of the day, it’s up to buyers to decide if they are willing to trust the Ray Horn brand or not.

jQuery to be integrated into Visual Studio

Good news for people who develop in the Microsoft development environments, jQuery is to be adopted in Microsoft’s official development platform. I’m surprised by the announcement as Microsoft has shown preference in developing their own products rather than reusing what is out there.

[ad#simple]

Adopting jQuery is an excellent choice and Microsoft probably would drop their existing ASP.NET Ajax Framework in time to come since so many people are using jQuery already.

What excites me more is the possibility of implementing jQuery IntelliSense into Visual Studio. I love to see how that would work out.

On slight note, Nokia also adopted jQuery in their widget development platform.

jQuery’s getJSON failing randomly in Internet Explorer

getJSON is perhaps the easiest method to erm get JSON with JavaScript using jQuery. JSON stands for JavaScript Object Notation, more information at Wikipedia.

The following piece of code is a really simple way to implement AJAX using the jQuery library:

I have a setInterval and each time Firefox will get the updated chat JSON every 10 seconds. But Internet Explorer has some issues, often return with old data.

And this is because of cache! The following code re-implements the above code to avoid caching issues.

To get back your data as JSON, remember to set dataType as “json”.

What cache: false does is that it appends a string of numbers such as “_=1211276828515” at the end of the URL.

GET http://localhost/chat.php?type=json&_=1211276828515

This number increases, it might be string of time in milliseconds or something, but it makes the browser thinks that the request is different from the previous.

I sat in front of the computer for an hour trying to figure out what’s wrong with my JavaScript or PHP code. Defeated by cache.