Script-injected ”async scripts” considered harmful

The inline JavaScript solution has a subtle, but very important (and an often overlooked) performance gotcha: inline scripts block on CSSOM before they are executed. Why? The browser does not know what the inline block is planning to do in the script it is about to execute, and because JavaScript can access and manipulate the CSSOM, it blocks and waits until the CSS is downloaded, parsed, and the CSSOM is constructed and available. ...

23 de mayo de 2014 · 1 min · 87 palabras · Nacho Cano

Introducing the HTML5 Hard Disk Filler„¢ API

The HTML5 Web Storage standard was developed to allow sites to store larger amounts of data (like 5-10 MB) than was previously allowed by cookies (like 4KB). localStorage is awesome because it’s supported in all modern browsers (Chrome, Firefox 3.5+, Safari 4+, IE 8+, etc.). The standard anticipated that sites might abuse this feature and advised that browsers limit the total amount of storage space that each origin could use. ...

27 de marzo de 2013 · 1 min · 75 palabras · Nacho Cano

Hacking the tag in 100 characters

A short while ago, I discovered that JavaScript allows you to change the href after you click on it. It may not seem that serious at first glance, but rest assured, it can trick customers into giving in their details to fraudsters. » bilaw.al

23 de marzo de 2013 · 1 min · 44 palabras · Nacho Cano

High Resolution Time

This specification defines a JavaScript interface that provides the current time in sub-millisecond resolution and such that it is not subject to system clock skew or adjustments. » Jatinder Mann | w3.org

28 de octubre de 2012 · 1 min · 32 palabras · Nacho Cano

Brainfuck beware: JavaScript is after you!

I just made a tool to transform any javascript code into an equivalent sequence of ()[]{}!+ characters. You can try it here, or grab it from github or npm. Keep on reading if you want to know how it works. What do you know about non-alphanumeric XSS? The other day one of my friends asked me that question on IRC, pointing me to some articles on sla.ckers.org where they tried to create some scripts like alert(1) with non-alphanumeric characters. As a security researcher and a penetration tester, he insisted that extending that concept to any javascript source would be really useful for bypassing IDSs, IPSs and WAFs. So challange accepted! ...

13 de agosto de 2012 · 1 min · 115 palabras · Nacho Cano

Key Principles of Maintainable JavaScript

The thing to remember, above all else when writing JS code, is that it’s a dynamic language. This means there are a lot of ways to do things. You don’t have to deal with strongly typed classes, or some of the more complex features from languages, like C# and Java. This is both a blessing and a curse. You can read an article on the history of JavaScript here, but the gist of it is that Brandon Eich, in 1995, was hired by Netscape to design a language. What he came up with was the loosely typed language that we know as JavaScript. Over the years, it became ”standardized” as ECMAscript, but, throughout all the browser wars, the various browsers implemented these features differently. This, naturally, lead to a lot of sleepless nights for web developers. This problem, when combined with the fact that JavaScript was considered to be most applicable for manipulating images and performing quick bits of validation, led JavaScript to, incorrectly, be viewed as a terrible language. ...

11 de julio de 2012 · 1 min · 175 palabras · Nacho Cano

El extraño caso de la función negada en Javascript

Tras este novelesco título lo que se esconde en esta ocasión es una estructura que podemos encontrar últimamente en bibliotecas y códigos de terceros. Se trata de una variante de las funciones autoejecutables (o que se auto invocan) que ya tratamos aquí hace algún tiempo. En concreto, se trata de la siguiente pieza de código: !function() { // My awesome code... }(); ¿Qué es exactamente esta función negada? ¿Cómo y porqué funciona? Echemos un vistazo a las tripas de Javascript¦ ...

26 de junio de 2012 · 1 min · 82 palabras · Nacho Cano

Mario5

In the history of computer games some games have created and carried whole companies on their shoulders. One of those games is certainly Mario Bros. The Mario character first appeared in the game Donkey Kong and became very famous within its own game series starting with the original Mario Bros. in 1983. Nowadays a lot of spin-offs and 3D jump and runs are being produced centering the Mario character. In this article we will develop a very simple Super Mario clone, which is easily extendible with new items, enemies, heros and of course levels. The code of the game itself will be written in object oriented JavaScript. Now that sounds like a trap since JavaScript is a prototype based scripting language, however, there are multiple object oriented like patterns possible. We will investigate some code which will give us some object oriented constraints. This will be very useful to stay in the same pattern through the whole coding. ...

21 de junio de 2012 · 1 min · 160 palabras · Nacho Cano

Client-Side vs. Server-Side Rendering

Yesterday Twitter announced that it was moving away from client-side rendering back to server-side rendering in order to improve page load time. Today I found myself having to defend my position that server-side rendering will almost always be faster. I figured I’d blog about it. I want to point out a couple things. First, I’m talking specifically about render performance and page speed. There might be other compelling advantages to thick-clients; I’m talking about performance. Secondly, I’m going to get on a high horse here and say that it worries me that developers think client-side rendering is faster. This is basic and fundamental knowledge about how the web and browsers work. Maybe I’ll be proven wrong. If I am, I’ll admit it. It’ll be embarrassing because it means that I don’t know the fundamentals. But I’ll be glad to have learned (which is why I blog). ...

4 de junio de 2012 · 1 min · 148 palabras · Nacho Cano

Application Cache is a Douchebag

Good morning! Over in ”castle Lanyrd” we recently launched our mobile site, which caches data on events you’re attending for viewing offline. I’ve boiled the offline bits down to a simple demo and posted all the code on Github. But before we delve into the code, let me tell you a true story. Totally true. » alistapart.com

22 de mayo de 2012 · 1 min · 57 palabras · Nacho Cano