So, what was happening in El Salvador before it gained independence? Well, the country was a Spanish colony, and the indigenous people, the Pipil and Nahuat, were being, shall we say, "managed" by the Spanish. It wasn't a great situation, and the locals were getting a little tired of being bossed around.
The Criollos, or Spanish-born elites, were in charge, and they were making all the decisions. But, as time went on, the criollos started to think, "Hey, maybe we should be in charge of our own country!" And, just like that, the seeds of independence were sown.
Fast forward to 1810, when the Mexican War of Independence inspired the people of El Salvador to start their own revolution. It was a messy time, with lots of fighting and negotiating, but eventually, the country declared its independence from Spain.