View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Timothy Appnel > JavaScript-Bookmarklet-0.02 > JavaScript::Bookmarklet



Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  


JavaScript::Bookmarklet - utility library and command-line script for converting human-readable JavaScript code into bookmarklet form.


  use JavaScript::Bookmarklet qw(make_bookmarklet);

  my $src = <<JAVASCRIPT
  var str = document.title;

  my $bookmarklet = make_bookmarklet($src);
  print $bookmarklet;

The output of this script would be:

  // javascript:var%20str%20=%20document.title;alert(str);
  var str = document.title;


A "bookmarklet" is a little JavaScript script that's intended to be run from a web browser's bookmarks bar or menu. The reason they work as "bookmarks" is that the JavaScript source code is crammed into the form of a URL using the "javascript:" scheme.

This package is based on a text filter John Gruber of Daring Fireball fame wrote that makes writing --- and especially revising --- JavaScript bookmarklets much more pleasant.

Developing or modifying bookmarklets can be irritating, to say the least, because of this requirement that the JavaScript code be in the form of a URL.

So the problem developing bookmarklets is this: You want to write and edit normal JavaScript code, but you need to publish hard-to-read URLs.

This package provides to means of using this functionality -- as a utility method that can be called in an application and as a script that can be used on the command-line or in editors like BBEdit.


make_bookmarklet $javascript, [$no_src]

This method takes a required SCALAR string ($javascript) that is presumed to be valid working JavaScript code and compresses it in to bookmarklet form. Optionally a boolean flag ($no_src) can be passed with the JavaScript code forcing the method to only return the bookmarklet screen and not the merged output of the bookmarklet and source code.

This method can be exported by request.


Bugs should be reported via the CPAN bug tracker at

For other issues, contact the author.


Timothy Appnel <>

SEE ALSO ^, make-bookmarklet


The software is released under the Artistic License. The terms of the Artistic License are described at Except where otherwise noted, JavaScript::Bookmarklet is Copyright 2008, Timothy Appnel, All rights reserved.

syntax highlighting: