Sign in with your Apple ID - Apple Developer. Safari and settimeout javascript function. Converting an existing Backbone.js project to Require.js | Eventual Consistency. Recently, I've undertaken the task of converting a rather large Backbone.js app to using Require.js. Since the process can get tricky at times, here's a quick recap of what I had to do to get it done. 0.
Why use Require.js in the first place? Most projects start small. A couple of script tags that include jQuery (or Zepto, or whatever else you are using), a couple of plug-ins, and your own code. Require.js helps us define exactly what our component depends on, almost like "regular" imports in other development environments. 1. OK so the first part is easy enough. . $ bower install requirejs (As a side-note, Bower and require.js work really well together). Once we have the library, we can add it to our project by adding a single <script> tag: that data-main attribute will tell require.js where to start. Also, this would be a good time to remove all other <script> tags you have lying around there. 2. This assumes the following structure: So what have we here? 3. 4. 5. 6. Comparatif des outils de développement multi-plateforme mobile. Jquery Mobile – PhoneGap – Retours d’expérience et bonnes pratiques. Lors du développement d’une application mobile, nous sommes souvent confrontés au choix “application native” ou “site web mobile”.
Dans cet article, nous allons présenter l’approche que nous avons eu pour le développement d’une application mobile qui mixe à la fois un framework html mobile classique avec l’utilisation de JQuery Mobile ainsi que des fonctionnalités natives grâce à PhoneGap. Nous verrons ensuite les bonnes pratiques que nous avons pu faire ressortir ainsi que les limites rencontrées. Notre application Le projet a pour but d’inventorier divers biens (matériel informatique,etc) via un appareil mobile. Cette dernière contient divers formulaires ainsi que des listes pouvant afficher plusieurs centaines d’éléments. L’application devait remplir plusieurs prérequis : Le choix de JQuery Mobile jQueryMobile est un framework qui permet, à partir de pages HTML/CSS/JS, d’obtenir des écrans ainsi que des composants graphiques adaptés au rendu smartphone ou tablette. Retours d’experience.
Know yourengines velocity2011. Javascript, retour aux bases : constructeur, prototype et héritage. Depuis quelques temps, l’utilisation du javascript se démocratise. De langage permettant de faire clignoter un texte ou défiler un bandeau de pub sur votre site multimania, il est progressivement devenu un outil à part entière de toute application web, jusqu’au point, atteint récemment, d’être auto suffisant, et ainsi de voir émerger un certain nombre de librairies permettant de réaliser la partie interface d’une application (presque) exclusivement en javascript. Pourtant, on partait de loin ! Très longtemps considéré par la majorité comme un language de bidouilleur tout juste bon à sortir du code inmaintenable, on aura tout entendu sur javascript : depuis « nan mais de toute façon javascript ca marche pas » jusqu’a « nan mais javascript c’est nul, c’est pas orienté objet : y a pas de classe » en passant par « nan mais moi le prototype j’ai rien pigé, pourquoi ils ont fait ca, sérieux ?
», sans oublier le fameux « c’est quoi ce mot clef ‘this’ qui change tout le temps ? Voila. Et oui ! What is the 'new' keyword in JavaScript. Is The Death Of JavaScript Upon Us, Or Is A Universal Language Transformation Underway? Editor’s note: Péter Halácsy is co-founder and CTO of Prezi. Follow him on Twitter @halacsy. Startups identify with JavaScript. When you’re just starting out, you need to be dynamic. You need to be flexible. You need to be able to bust out a prototype that just works, and you need to be able to change it on a dime without recompiling your code. JavaScript was once the startup of the browser wars, and it crushed Java and Flash for the same reasons that startups have the ability to disrupt markets and displace the established players: agility and flexibility.
Today, JavaScript is no longer a startup, and it’s no longer just startups that are using it. Those in the latest generation of JavaScript engines deliver incredible performance gains, but these still aren’t enough. Once your codebase reaches hundreds of thousands of lines of code, and it’s all written in a dynamic language such as JavaScript, development velocity starts to suffer. AMD/RequireJS shim plugin for loading incompatible JavaScript | Tim Branyen @tbranyen. When Jeremy Ashkenas decided to remove AMD compatibility completely from the DocumentCloud projects, Underscore & Backbone I wasn't quite sure what to think. On one hand it would have been great for the community to have decided on an open standard to write and load modules. On the other hand, it seemed like a dark path for a library to head down if it wasn't completely on board. This got me thinking about Backbone Boilerplate and what I could do to help provide the desired RequireJS/AMD interoperability.
Creating a boilerplate that patches the source files of the libraries has been done to death and only puts a band-aid on the problem instead of solving it. On a more personal opinion, I'm never in favor of patching third-party JavaScript by hand, unless its an extreme circumstance (patching an exploit). I thought about all the reasons why I wasn't currently using RequireJS in any of my projects. Here are a few of the immediate reasons: define(["order! Screw Hashbangs: Building the Ultimate Infinite Scroll. I’m just a student in a field unrelated to computer science, but I’ve been coding for years as a hobby. So, when I saw the current state of infinite scroll, I thought perhaps I could do something to improve it. I’d like to share what I came up with. (Demo: The impatient can just try it out by scrolling+navigating away+using the back button on the front page of my site. Works in current versions of Safari, Chrome, Firefox.)
Hashbangs Lie Anybody that has even casually coded JavaScript over the past two years can tell you the story: Google proposed using the hashbang (#!) But the real problem is the lying. Hashbangs for Lunch Let’s say you are at a restaurant. Case 1cafe.com/entrees/burger/ketchup/ If the server accepted your order with a URL sans fragment identifier, then you get everything at once, your ketchup is on the side of your plate, and you can immediately begin enjoying your delicious burger. Case 3cafe.com/#! “What the heck is going on?” Well, yes. Here’s a helpful illustration: Js2coffee: convert JavaScript code to CoffeeScript.
Writing polyfills in Javascript. Introduction Javascript is notorious for having cross-browser compatibility issues. Internet Explorer, Mozilla Firefox, Google Chrome, Safari and Opera all have their own proprietary features and their own subset of the standard features. Different browsers implement each feature in their own way, and this can be a major headache for web developers trying to make things work for everybody. Fortunately, Javascript has enough flexibility and extensibility to bridge some of these gaps between each browser. These bridges are called polyfills. We will create a few simple polyfills to see how they work.
What is a polyfill? A polyfill is a piece of code that implements the features that you expect the browser to support natively. Polyfills usually emulate a newer API that provides fallback functionality to older browsers. There are varying degrees of completeness for a polyfill: Perfect polyfills are polyfills that perfectly implement features completely without any side effects. Feature detection. Client Side Frameworks. Isomorphic JavaScript: The Future of Web Apps. By Spike Brehm This post has been cross-posted on VentureBeat. At Airbnb, we’ve learned a lot over the past few years while building rich web experiences. We dove into the single-page app world in 2011 with our mobile web site, and have since launched Wish Lists and our newly-redesigned search page, among others. Each of these is a large JavaScript app, meaning that the bulk of the code runs in the browser in order to support a more modern, interactive experience.
This approach is commonplace today, and libraries like Backbone.js, Ember.js, and Angular.js have made it easier for developers to build these rich JavaScript apps. JavaScript Grows Up Since the dawn of the Web, the browsing experience has worked like this: a web browser would request a particular page (say, “ causing a server somewhere on the Internet to generate an HTML page and send it back over the wire. The Single-Page App Trouble in Paradise Performance Maintainability A Hybrid Approach Routing.
Node.js. JavaScript Garden. Although JavaScript deals fine with the syntax of two matching curly braces for blocks, it does not support block scope; hence, all that is left in the language is function scope. function test() { // a scope for(var i = 0; i < 10; i++) { // not a scope // count } console.log(i); // 10} There are also no distinct namespaces in JavaScript, which means that everything gets defined in one globally shared namespace. Each time a variable is referenced, JavaScript will traverse upwards through all the scopes until it finds it. In the case that it reaches the global scope and still has not found the requested name, it will raise a ReferenceError. The Bane of Global Variables // script Afoo = '42'; // script Bvar foo = '42' The above two scripts do not have the same effect.
Again, that is not at all the same effect: not using var can have major implications. // global scopevar foo = 42;function test() { // local scope foo = 21;}test();foo; // 21 Local Variables var foo = 3; bar = 4;}test(10); Hoisting.