background preloader

Javascript

Facebook Twitter

Namespacing in JavaScript. Global variables should be reserved for objects that have system-wide relevance and they should be named to avoid ambiguity and minimize the risk of naming collisions.

Namespacing in JavaScript

In practice this means you should avoid creating global objects unless they are absolutely necessary. But, hey, you already knew all that….. My Favorite JavaScript Design Pattern. I thought it might be interesting to look at a JavaScript design pattern that I use a great deal.

My Favorite JavaScript Design Pattern

I settled on it gradually, over a period of time, absorbing and adapting influences from various sources, until reaching a pattern that offers the flexibility I need. Let me show you an overview, and then look at how it comes together: Design Patterns for JavaScript Applications. Writing Modular JavaScript With AMD, CommonJS & ES Harmony. When we say an application is modular, we generally mean it's composed of a set of highly decoupled, distinct pieces of functionality stored in modules.

Writing Modular JavaScript With AMD, CommonJS & ES Harmony

As you probably know, loose coupling facilitates easier maintainability of apps by removing dependencies where possible. When this is implemented efficiently, its quite easy to see how changes to one part of a system may affect another. Unlike some more traditional programming languages however, the current iteration of JavaScript (ECMA-262) doesn't provide developers with the means to import such modules of code in a clean, organized manner. Brian Ford. AngularJS is like the missing Batarang on your utility belt of web development awesomeness.

Brian Ford

Climb That Mountain: JavaScript Testing with Mocha. JavaScript is a neat and powerful language.

Climb That Mountain: JavaScript Testing with Mocha

Sure it has its flaws, but serious software can be developed with it. The way I prefer developing JavaScript applications is by test driving the code with some kind of testing tool. And I am not thinking about hitting the browser's refresh button. Sur la route d'Oxiane » Blog Archive Application AngularJS avec Yeoman, Express et JewelryBox sous Mac OS X. Yeoman a été créé dans l’optique de faciliter l’initialisation de web apps JavaScript, en regroupant un ensemble de 3 utilitaires tournant sous Node.js :

Sur la route d'Oxiane » Blog Archive Application AngularJS avec Yeoman, Express et JewelryBox sous Mac OS X

CoffeeScript vs. TypeScript by Paul Oliver on Prezi. Popline - An HTML5 Rich-Text-Editor Toolbar. Why did we build React? There are a lot of JavaScript MVC frameworks out there.

Why did we build React?

Why did we build React and why would you want to use it? React isn't an MVC framework. Popline - An HTML5 Rich-Text-Editor Toolbar. A plain english guide to JavaScript prototypes - Sebastian's Blog. Drive SDK: New Undo feature for the Realtime API. 01-core.js. TraceGL.

AngularJS

Airbnb/javascript. Infinity.js. A ListView is a container that moves content in and out of the DOM on the scroll event.

Infinity.js

ListViews help keep repaint times of expensive pages down (and scrolling smooth) by making sure that there are never too many elements onscreen at a single time. ListViews excel at speeding up long lists of complex HTML elements, where new content is frequently appended to the end and existing content is rarely removed. ListViews are simple, and have several caveats: they can't be nested inside each other, and they can't have heights set via CSS.

Additionally, ListViews can't easily change sizes except by appending or removing elements, and so list items that need to slide open or change their sizing will be difficult to implement. Our First Node.js App: Backbone on the Client and Server. Here at Airbnb, we’ve been looking curiously at Node.js for a long time now.

Our First Node.js App: Backbone on the Client and Server

We’ve used it for odds and ends, such as the build process for some of our libraries, but we hadn’t built anything production-scale. Until now. The Problem There’s a disconnect in the way we build rich web apps these days. In order to provide a snappy, fluid UI, more and more of the application logic is moving to the client. Location.hash is dead. Long live HTML5 pushState! For a long time, location.hash was a way for AJAX applications to get back button and bookmarking support, and libraries like jQuery BBQ from Ben Alman made dealing with it cross browser a cinch.

location.hash is dead. Long live HTML5 pushState!

Now, with HTML5 coming of age, there is a new feature that aims to replace the use of location.hash with a better solution: pushState. Over on the Spoiled Milk blog, Jamie Appleseed describes the API as “a way to change the URL displayed in the browser through JavaScript without reloading the page.” Demander confirmation à la fermeture d’un onglet en javascript. Votre utilisateur est en train d’écrire un commentaire, upload un ficher ou fait un truc quelconque qui n’est pas terminé. Puis il clique sur “fermer l’onglet”. Dans certains cas, vous voulez lui demander confirmation pour éviter qu’il perde tout son travail. var confirmOnLeave = function(msg) { window.onbeforeunload = function (e) { e = e || window.event; msg = msg || ''; // For IE and Firefox if (e) {e.returnValue = msg;} // For Chrome and Safari return msg; }; }; // message de confirmation générique du navigateur confirmOnLeave(); // message de confirmation personnalisé confirmOnLeave('Vous allez perdre votre travail, êtes vous sûr(e) de vouloir quitter la page ?

') Making Use of jQuery UI’s Widget Factory. For a long time, the only way to write custom controls in jQuery was to extend the $.fn namespace. This works well for simple widgets, however, as you start building more stateful widgets, it quickly becomes cumbersome. To aid in the process of building widgets, the jQuery UI team introduced the Widget Factory, which removes most of the boilerplate that is typically associated with managing a widget. The widget factory, part of the jQuery UI Core, provides an object-oriented way to manage the lifecycle of a widget. A Few New Things Coming To JavaScript.

I believe the day-to-day practice of writing JavaScript is going to change dramatically for the better when ECMAScript.next arrives. The coming year is going to be an exciting time for developers as features proposed or finalised for the next versions of the language start to become more widely available. In this post, I will review some of the features I'm personally looking forward to landing and being used in 2013 and beyond. ES.next implementation status Be sure to look at Juriy Zaytsev's ECMAScript 6 compatibility table, Mozilla's ES6 status page as well as the bleeding edge versions of modern browsers (e.g Chrome Canary, Firefox Aurora) to find out what ES.next features are available to play with right now.

In Canary, remember that to enable all of the latest JavaScript experiments you should navigate to chrome:flags and use the 'Enable Experimental JavaScript' option. AngularJS and SEO. Turns out it is possible to have your AngularJS application indexed AngularJS and just about all JavaScript MVC frameworks modify the contents of your HTML structure which make the pre-rendered HTML invalid for search engines.

Luckily there is a way to get around this and to have full SEO support for your AngularJS application by using some special URL routing and a headless browser to retrieve the HTML for you. Continue reading this article to figure out how to make this amazing framework work well with your favourite search engines. Airbnb/javascript. Plupload - A tool for uploading files using Flash, Silverlight, Google Gears, HTML5 or Browserplus. Désactiver le WiFi de la Freebox à certaines heures.

Flip Clock. ෴ browserver: a node.js HTTP server in your browser ෴ Twitter Bootstrap Notifications, from Nijiko Yonskai. Le Programmeur Moderne - Le JavaScript moderne. Ces dernières années, l'utilisation de JavaScript a évolué jusqu'à en faire un incontournable du web. L'écrasante majorité des navigateurs supportent JavaScript, que ce soit pour les ordinateurs de bureau ou les téléphones portables. Les navigateurs web optimisent continuellement leurs moteurs JavaScript et les développeurs en profitent pour apporter des applications entières sur le web. Le succès de JavaScript est tel qu'il s'étend désormais à d'autres usages : Node.js, CouchDB ou encore Meteor utilisent JavaScript pour créer des sites web, mais cette fois aussi du côté serveur ! Un seul langage est utilisé, ce qui facilite le développement.Les applications de bureau ne sont pas en reste : JavaScript fera partie des langages supportés pour écrire des applications dans Windows 8 et Qt 5, deux mastodontes pour les interfaces utilisateur de demain.

Chroniques jQuery, billet 71. Datavisualization.ch Selected Tools. Google JavaScript Style Guide. We follow the C++ formatting rules in spirit, with the following additional clarifications. Curly Braces Because of implicit semicolon insertion, always start your curly braces on the same line as whatever they're opening. For example: if (something) { // ... } else { // ... } Array and Object Initializers. Closures: Front to Back. Closures are often viewed as an arcane art in the land of JavaScript.

Once mastered, they allow you to write some truly amazing JavaScript. This article will get you up to speed on the magic of JavaScript closures.

Node.JS

3D in Apps Script.