Bookmarklets
 
How Big can a Bookmarklet Be?

...sadly, I still don't know.

The first generation of bookmarklets was limited in size to 255 characters, which means that only 255 symbols could be used to describe the action enabled by the bookmarklet.
There is some reasoning behind this...

How big can a URL be?
Bookmarklets fit into spaces designed to handle webpage addresses (URLs - Uniform Resource Locators), so they can't be any bigger than the largest URL. Problem is, there is no absolute standard which sets a "largest URL". In fact, the original specification which defined the concept of URLs intended no bound there. [Tech note: You won't find it stated that way in RFC 1738, but I have it from the kind correspondence of the first author that no bound is intended.]

Despite the theoretically unlimited size of a URL, people have had to make software for machines that are very limited in size, making a compromise between the theoretical and the practical. And they've made that compromise in different ways.
This difference can show up when somebody gives a bookmarklet to someone else...

The gift-path of a bookmarklet:
Suppose Ricky has a bookmarklet that Lucy wants. Maybe Ricky found the bookmarklet on a webpage and added it to his bookmarks/favorites. So he copies it and sends it to Lucy during an internet messaging session, using the URL-sharing feature of their messaging system. Now suppose further that Lucy likes the bookmarklet and decides to share it with her friends by using the URL-adding feature of her webpage editor. And then what if Ethel sees it and puts it in her online bookmark manager until retrieving it for Fred, who stores it in his handheld device until beaming it to Gilligan...

The point is that a bookmarklet could conceivably have to pass through many kinds of software, each of whose authors made their own decisions about how long a URL should be and what to do with longer ones. The author could have decided that longer bookmarklets need to be chopped down to size; bookmarklets, like any kind of program, usually do not survive even a mild chopping - they usually complain if even one symbol is missing from their end.
So it was necessary to make an educated guess about the size that would survive sharing.

But why 255?
Computers are binary things and so space on them tends to get allocated in sizes that are powers of two. If you raise 2 to the power 8 you get 256. The guess was that 128 (=27) symbols was too small for some real-world webpage addresses - 256 was next. As an added precaution, 256 was reduced to 255 to allow the presence of "check digits" and such.
This proved to be a pretty good guess. For example, when the editors of the ODP created bookmarklets to help them catalog URLs, they found that the ODP database expected URLs to be no more than 256 symbols long.

Isn't 255 completely arbitrary?
Yes. It's both arbitrary and stupid, in the long run.

What could be done with more room?
The usefulness of a program can increase much faster than its size in symbols because in longer programs there is more room for more loops (loops provide a lot of "bang per byte"). If you double the allotted size, you get much more than twice the benefit.

How big can a bookmarklet be?
We return to the central question. At bookmarklets.com we currently see the benefit of accepting bookmarklets of size up to 500 symbols. The second generation will permit this new limit. This means that some newer bookmarklets will break on some kinds of software.

Some guidelines for software developers:
If you are developing software that handles URLs as special objects:
1) Design your system with the understanding that URLs can be of arbitrary (or excessively long) length.
2) If you must impose a limit on the length of a URL, put it at 1024 symbols or more, and if this is too long, admit that your software only expects to handle URLs of small length, intelligently rejecting long URLs and/or URLs using the javascript: protocol.

The future of unlimited functionality
We'll do our best to up the bar, but some brave explorers will have to step up to sail their browsers into the uncharted waters of very big bookmarklets. Intrinsically, the usefulness of bookmarklets will increase quickly with the room in which they live; extrinsically, we are motivated to advance such explorations in accord with the safety and comfort of our visitors.

I don't know how big a bookmarklet can be... I only know that the bigger it can be, the better it can be.


Steve Kangas
Nov. 25, 2000