Skip to content

22 de Janeiro de 2009

How global is your JavaScript?

Mats Bryntse “had an idea about check­ing the most pop­u­lar javascript frame­works & APIs to see how they dif­fer in terms of global name­space pol­lu­tion. This page loads all the frame­works sep­a­rately in an iframe and com­pares the win­dow object against the one of a fresh iframe. I also included infor­ma­tion about which builtin JavaScript classes have been aug­mented, not sure how that would be use­ful but it shows a dif­fer­ence in archi­tec­tural approach between the frame­works. You can click a row to see the details about the global sym­bols in the framework/API.

The results vary more than I’d expected and it’s inter­est­ing to see the dif­fer­ent name­spacing strate­gies at play. YUI/Jquery/Ext keep the num­bers down by putting every­thing in one global object. It seems like Microsoft is using their own kind of name­spacing using the $ sign as a name­space delim­iter rather than using real object prop­er­ties as the rest of the frame­works do.”

You can check this out via his checker page. An inter­est­ing read and you can nar­row in on APIs of your choice.

We like to talk about how evil global vari­ables are, but I won­der if we take this a touch too seri­ously some­times. Sure there can be col­li­sions and the like, but a lot of projects are doing just fine :)

via : ajaxian.com

Be Socia­ble, Share!

Read more from JavaScript

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

Spam protection by WP Captcha-Free

Bad Behavior has blocked 58 access attempts in the last 7 days.