Simon Willison’s Weblog

Subscribe

Items tagged javascript in 2012

Filters: Year: 2012 × javascript × Sorted by date


If I study HTML5, can I avoid having to learn javascript?

Many of the most exciting new features that fall under the term HTML5 only make sense in the context of JavaScript—things like Canvas, Web Workers, AppCache and so on. So no, you can’t learn HTML5 properly without getting familiar with JacaScript.

[... 60 words]

Can you mark items on a website as ’unread’ without cookies?

It’s not very exciting, but CSS will let you set different styles for visited vs unvisited links and the technique has worked reliably since the mid 1990s.

[... 44 words]

How difficult is to to learn a language framework, like node.js?

The answer varies enormously depending on the language and the framework. Some frameworks are very easy to pick up, others are harder.

[... 162 words]

What is a good cat name that relates to JavaScript?

I have two friends with cats that have names related to JavaScript. One is called “JavaScript” and the other is called “Widget”.

[... 38 words]

Wouldn’t an ASCII cellular automaton in javascript be the simplest starting point to teach/learn programming?

Absolutely not. The first step in learning to program is understanding that a computer can be quickly made to do something useful by executing lines of code. Personally I’m a big fan of firing up something with an interactive prompt (like Python, or even Firebug or the Google Chrome JS console) and demonstrating that typing a line of code hitting return will get a useful response.

[... 87 words]

How do you change page content and URL without reloading the whole page?

This can only be done using JavaScript. You use XMLHttpRequest to pull in new information from the server (also known as Ajax—most people use a JavaScript library such as jQuery to handle this) and then use the HTML5 history API, in particular the pushState method, to update the URL.

[... 133 words]

How can I parse unquoted JSON with JavaScript?

Unquoted JSON isn’t JSON—the JSON spec requires that strings are quoted (with double quotes, not single quotes).

[... 104 words]

Was CoffeeScript invented to help Ruby programmers get over that dirty yucky feeling they get when working in JavaScript?

The original Prototype JS library might fit that description—more than CoffeeScript, at any rate.

[... 41 words]

How long until Ruby developers are as cheap as PHP developers? is it already happening? should I still learn it or it only has a couple years left and I’m better off with SSJS?

If you want to be a highly paid engineer, you should worry less about your expertise in a specific language and more about developing broad and deep skills across a wider range of development topics.

[... 197 words]

How is JSON different then a JavaScript (programming language) object?

JSON is a carefully selected subset of JavaScript. A JSON object can only consist of dictionaries, strings, numbers (in JavaScript floating point and integers are treated as the same thing), lists, booleans and null. The spec on JSON.org is a good guide: http://json.org/

[... 119 words]

Is there a method to programmatically clear browser cache in JavaScript?

No.

[... 18 words]

Are there any performance drawbacks when rendering DOM views at runtime with JavaScript, rather than rendering server-sent HTML?

Yes, there is quite a significant impact on first-load performance. The browser has to pull down all of the linked scripts before it can display any content—if you’re using a library like jquery that’s a sizeable chuck of code that has to be loaded and executed just on its own.

[... 152 words]