wag (n.1)

"person fond of making jokes," 1550s, perhaps a shortening of waghalter "gallows bird," person destined to swing in a noose or halter, applied humorously to mischievous children, from wag (v.) + halter. Or possibly directly from wag (v.); compare wagger "one who stirs up or agitates" (late 14c.).

wag (n.2)

"act of wagging," 1580s, from wag (v.).

wag (v.)

early 13c. (intransitive), "waver, vacillate, lack steadfastness," probably from a Scandinavian source (compare Old Norse vagga "a cradle," Danish vugge "rock a cradle," Old Swedish wagga "fluctuate, rock" a cradle), and in part from Old English wagian "move backwards and forwards;" all from Proto-Germanic *wag- (source also of Old High German weggen, Gothic wagjan "to wag"), probably from PIE root *wegh- "to go, move, transport in a vehicle."

Transitive meaning "move (something) back and forth or up and down" is from c. 1300; of dogs and their tails from mid-15c.: "and whanne they [hounds] see the hure maystre they wol make him cheere and wagge hur tayles upon him." [Edward, Duke of York, "The Master of Game," 1456]. Related: Wagged; wagging. Wag-at-the-wall (1825) was an old name for a hanging clock with pendulum and weights exposed.