Archive for the 'JavaScript' Category

JavaScript: Calling the unnamed

Aug 16th, 2007

How does this look like? o[“”]() A bit like a syntax error, eh? Or an emoticon of some sort. Well, it’s valid JavaScript code. JavaScript objects can have an empty string as a name for a property/method. So if you create an unnamed method called “”, you can’t call it using the dot notation, but […]

 

Order of execution of event listeners

Aug 14th, 2007

Say you attach several listeners to an event, for example you want a few things to happen on page load. What is the order of execution of the different listeners? You’d think that the listener attached first will execute first, followed by the second and so on… Well, yes, in FF, Opera, Safari on Windows, […]

 

JavaScript patterns (dot com)

Jul 22nd, 2007

I had this idea of collecting better javascript practices and … well, patterns. The thing is that there is so much bad javascript floating around from the time of “copy/paste this to make your status bar go crazy”, so there should be more of the good JS kind to replace the bad one. I liked […]

 

A JavaScript implementation of the Decorator pattern

Jul 17th, 2007

For background information on the decorator pattern check the Wikipedia article or for PHP implementations, here and here. Motivation and example use Let’s take an example – you’ve created a class and released to the world. You want people to be able to easily build upon it and also release to the world. Some other […]

 

PHP/Javascript dev tools for TextPad

Jul 16th, 2007

Here are some convenient tools I’ve added to my TextPad editor, hope you’ll like ’em. TextPad tools Stuff can easily be added to TextPad’s Tools menu, like I did, shown on the screenshot. In order to do so, you go Configure -> Preferences. Then select Tools on the tree to the left, then Add. You […]

 

On a publishing diet

Jul 12th, 2007

So I launched this little tool csssprites.com that allows you to upload images and create one CSS sprite image, plus it gives the background-position CSS definitions to use in order to show parts of the sprite. People have been trying it out, but unfortunately sometimes uploading 20 megs of images to create a sprite, which […]

 

CSS Sprites generation tool

Jun 27th, 2007

Here’s my last weekend’s project – a web-based tool to generate images for CSS sprites: http://www.csssprites.com. Cool domain name, eh? I couldn’t believe it was not taken. CSS Spr…what? This is a simple technique used for page load performance purposes. Since HTTP requests are the most expensive thing you can do in regards to front-end […]

 

Weird attempt for flicker-free rendering solution

Jun 23rd, 2007

Flicker-free rendering – not allowing the user to see the page loading progress or how the different elements get downloaded and put at their right place. Extra points if the URL in the address bar doesn’t change. Why not use AJAX to only change part of the page? Well, don’t look at me, but sometimes […]

 

YUI anywhere (bookmarklet)

Jun 8th, 2007

Hooked on YUI? You can now take it anywhere you go. The thing is Yahoo hosts the libraries publicly, so they are available at any time. Let’s say you visit a page and you want to do something with it. Comes the YUI bookmaklet that adds a new script tag to the page pointing to […]

 

YUI good for your performance

Apr 1st, 2007

One of the cons of using any of the good and popular third-party JS libraries is the file size of the .js files associated with them. A lot has been done by the library developers to address this issue – providing minified versions, segregating the script files based on what they do and using loading-on-demand, […]

 

Two bookmarklets for debugging in IE

Feb 20th, 2007

Here are two bookmarklets that could make your life easier when trying to figure out why in IE a page behave as wrong as it behaves. For Firefox we have Firebug, so none of this is necessary. For IE we have also Firebug lite (see my post), but you need some setup before you can […]

 

JSON data island

Feb 12th, 2007

Here’s a hacky thing, I called it JSON data island, referencing the XML data island, that MS came up with for their IE browser. The idea is to use a comment in your HTML that holds some data in JSON format. Then using DOM, you access the comment, eval()-uate it and there you go – […]

 

Check/toggle ’em all

Feb 10th, 2007

Recently I decided to clean up all the spam from an abandoned phpBB forum of mine, there was a lot to delete. In the phpBB version that I use there is no option to “check all” topics you want to moderate. So I came up with a little bookmarklet to do this for me. Here […]

 

AJAX-MCV in Russian

Jan 29th, 2007

Boris of http://www.ajaxplanet.ru/ has published a translation of my article on the little AJAX/MVC framework I came up with, this is trully flattering, thanks a lot! If you speak Russian check the post here. The translation is by Gennady Potapov, sposibo Gennady!

 

Dynamic SCRIPT and STYLE elements in IE

Jan 26th, 2007

So you know how to add external scripts and styles, using the DOM, after the page is loaded. And what if you don’t have external files, but have some style definitions and some JS code as text and you want it inserted and executed into a page. The DOM way “Ha! An easy one”, you’d […]

 

User stylesheet in IE

Jan 20th, 2007

Let’s say you want to quickly try out some small stylesheet changes, but you don’t want to (or prefer not to, or for some reason temporarily you just can’t) modify your application’s CSS file(s). In FF it’s easy – you have Firebug and you can play with styles until blue in the face. And in […]

 

Firebug console for IE

Dec 6th, 2006

Update: A better version of what I was trying to do is here. It works around the cross-domain permission problems in IE by not loading a page in the frame, but putting there the actual content. Firebug – no words to describe how cool it is, really. After the recent new release (1.0. beta) the […]

 

Y! homepage – CSS sprites in action

Dec 1st, 2006

Have you looked at the HTML markup of the new Yahoo homepage? Then you should. The markup (although it won’t validate) is a piece of semantic art. Lists are lists, tabs are lists, only one table to be seen (obviously plugged-in coming from a different site) The total number of markup elements on the page […]

 

JSON renderer for Text_Highlight

Oct 27th, 2006

Text_Highlighter is one of my favourite PEAR packages, seems like I’m addicted to highlighting source code. After adding BB code and simple HTML renderers and an ABAP code syntax definition, today I played with adding a JSON renderer. Useful in case you want to get highlighted source code in your new shiny AJAX app. Array […]

 

JS includes – the saga continues…

Oct 25th, 2006

The problem in question is how to find out a dynamically included JavaScript file is actually loaded. The concept of JavaScript includes is here, the IE-only solution is here. The IE solution is to use the onreadystatechange event that is fired when a new script is included. It also works for dynamically loaded CSS files […]

 

Deferring scripts for faster rendering

Oct 23rd, 2006

So it turns out one can defer scripts, meaning give the browser a hint that a script will not mess up with the page right now, so it won’t affect the rendering and can be delayed for later. This could give you increased performance during the initial page load and rendering, since you’re giving the […]

 

When is a JavaScript include ready?

Oct 23rd, 2006

This is a follow up to my article (the most popular on my blog based on the comments) about the JavaScript includes, the technique to include new .js files after the page is loaded, by using DOM to create a new script tag. The problem that is discussed in the comments is how to find […]

 

Yahoo API search with JavaScript alone

Oct 12th, 2006

Previously I’ve mentioned how I do image searches with my bigger daughter, hunting for images of Cinderella, Ariel the little mermaid, and other equally beautiful princesses. So I thought why not build a custom little app for the little kid to do this, I mean, her, being the good (and beautiful) girl that she is, […]

 

OPML to HTML via JavaScript

Oct 6th, 2006

Earlier today in a discussion with the lovely Amy Stephen, I thought of posting the RSS feeds I read. So I was thinking I would need to approach this in a good old web 1.0. way, finding a way to scrap content from the Google Reader. Luckily for me, I saw they have an Export […]

 

3 ways to define a JavaScript class

Sep 29th, 2006

Introduction JavaScript is a very flexible object-oriented language when it comes to syntax. In this article you can find three ways of defining and instantiating an object. Even if you have already picked your favorite way of doing it, it helps to know some alternatives in order to read other people’s code. It’s important to […]