Loading an external javascript file from a bookmarklet is a good way to give superpowers to your favelet, and achieve what we really want, without care about the stupid 512 characters limit Internet Explorer has or without write all the code as an ugly one liner. And not to mention other advantages like server compression (i.e. js chunked and minified, gzip, …), PHP pre-processing and so on, that makes this technique in a very powerful resource when developing bookmarklets.
This post is because I recently discovered that Safari browser is a little picky when using this technique.
For example, what in other browsers (Firefox, Opera and IE) works like a charm, in Safari does not:
Note: Examples are really one liners but presented multiline for better reading.
<a href="javascript:void(
z = document.body.appendChild(document.createElement('script'));
);
void( z.language = 'javascript' );
void( z.type = 'text/javascript' );
void( z.src = 'http://blabla.com/test.js' );
void( z.id = 'testScript' );
">
To make Safari happy we have to polish it a little bit:
[...]