From: Dr. Jamieson's Scottish Dictionary and Supplement, 1841
"Formed perhaps from the idea of any thing that is so haggit or hacked, as to be nearly cut off, to hang only by a tag or tack."
From: Sentimental Tommy,
The Story of His Boyhood.
By J.M. Barrie, 1896
Chapter XIV, The Hanky School