There are several ways to do that. I think you already have one solution.
Another solution is to define a subclass of Link and override Link.computePoints. Something like:
function UnseenShortLink() {
go.Link.call(this);
}
go.Diagram.inherit(UnseenShortLink, go.Link);
UnseenShortLink.prototype.computePoints = function() {
var result = go.Link.prototype.computePoints.call(this);
if (result) {
var first = this.getPoint(0);
var last = this.getPoint(this.pointsCount-1);
this.opacity = (first.distanceSquaredPoint(last) < 36) ? 0.0 : 1.0;
}
return result;
};
Use this class by replacing go.Link with UnseenShortLink in your Link template(s). Replace 36 with whatever value suits your needs.
Caution: I haven’t actually tried this code!