I think y'all are con-fusing a lot of different senses of (or perhaps different *words spelled) "rag". perhaps this is also why this particular sense is given as "origin unknown".

M-W differentiates between (i.e., has separate entries for) 1) rag : to rail at, scold; torment, tease, and 2) [chiefly Brit.] rag : an outburst of boisterous fun; prank.

as to the OneLook sidebar def'ns, remember that what gets listed there is only stuff that can be freely quoted 'cuz it's in the public domain; e.g., the 1913 or 18?? Webster's or perhaps something even less further removed from the mother-land.

and ragtime almost certainly connotes ragged rhythm.