The Supreme Court on Wednesday ruled for a Pennsylvania cheerleader whose profane off-campus rant cost her a spot on the squad, saying the punishment violated her First Amendment rights.

The court ruled 8 to 1 that the punishment was too severe, although it declined to say schools never have a role in disciplining students for off-campus speech.

“It might be tempting to dismiss B. L.’s words as unworthy of the robust First Amendment protections discussed herein,” Justice Stephen G. Breyer wrote in his 11-page majority opinion.

“But sometimes it is necessary to protect the superfluous in order to preserve the necessary.”

Brandi Levy — now an 18-year-old college student — was a frustrated ninth-grader when she lamented being passed over for the varsity cheerleading squad at Mahanoy Area High School. On a spring Saturday in her freshman year, she posted on Snapchat a photo of herself and a friend with upraised middle fingers and this rant.

“F— school, f— softball, f— cheer, f— everything.” It was sent to about 250 friends, including fellow cheerleaders at her school.

It was supposed to disappear in 24 hours, but her cheerleading coaches were alerted to it, and Levy was suspended from cheerleading for a year — but not from school….