There WERE anti-communist LAWS until the 1950’s.
And they were supported by Democrats. Judge Harold Medina, a prominent Democrat, presided over the sensational 1949 trial of several Communists charged with violating the Alien Registration Act, aka the Smith Act (they were convicted), and liberal Senator Hubert Humphrey voted for the Communist Control Act of 1954.