 Spain initially sided against France in the Napoleonic Wars, but the defeat of her army early in the war led to Charles IV's pragmatic decision to align with the revolutionary French.Spain was put under a British blockade, and her colonies began to trade independently with Britain but it was the defeat of the British invasions of the Río de la Plata in South America (1806 and 1807) that emboldened independence and revolutionary hopes in Spain's North and South American colonies.A major Franco-Spanish fleet was lost at the Battle of Trafalgar in 1805, prompting the vacillating king of Spain to reconsider his difficult alliance with Napoleon.