I would suggest you read Six Frigates. It’s about the founding of the U.S. Navy which was largely because of the predation of the Barbary Pirates. After some stumbling they kicked Jihadi Joes potomus. First by themselves in 1805 and then with the British in 1816. The campaigns are where the U.S. Marines got their “to the shores of Tripoli” line in their anthem.
thanks so much for such an interesting tip for history’s sake.