How to strip out javascript in wp_posts `post_content`

If the javascript code is actually embedded in the post content, you could use php filters such as the_content to remove script tags. But that will strip it out at runtime, every time the page is loaded. If this is your situation, then you’d be better off stripping it out of the wp_posts.post_content table/column from the database.

If you want to quickly strip out the content just for display, you can use the the_content filter, like so (in your theme’s functions file)

add_filter('the_content', function($content){
    return wp_kses_post( $content );
});

But again, this will run every time the page is loaded. It’s more of a short term fix.