8

Here's how I make develop a bookmarklet: I write a javascript function, pass that to Bookmarklet Builder to make a bookmarklet, add the bookmarklet to my browser, load my test webpage, test the bookmarklet, and then something doesn't work, so I try to find what's wrong and change my javascript function accordingly and the tedious cycle starts again.

How can I make this cycle less tedious?

Yoo
  • 17,526
  • 6
  • 41
  • 47

2 Answers2

17

These days I prefer to edit a file on my webserver, then load that using a bookmarklet. For example:

javascript:(function(){
    var newScript = document.createElement('script');
    newScript.src = 'http://hwi.ath.cx/javascript/wordcloud.js?dummy='
                     + Math.random();
    document.body.appendChild(newScript);
})();

The random parameter is useful for a script under development, to ensure the browser won't load an older version from its cache.

I find development with a text editor far preferable to the console, because I can take advantage of syntax highlighting, shortcut keys, and — you know — newlines.

joeytwiddle
  • 29,306
  • 13
  • 121
  • 110
  • These days the URL should probably be `//your.domain/path` so that it will use http or https depending on the current page. But beware, many well-secured sites will block scripts loaded from unknown sites (CSP). So this approach might not work so well in 2018, depending where you are using it. – joeytwiddle Dec 28 '18 at 06:18
10

use the firebug console to develop and test your function, and turn it into a bookmarklet once you've got it working like you want to.

Breton
  • 15,401
  • 3
  • 59
  • 76