Islam spread into Indonesia through Muslim traders from India and Arabia and by later some Indonesian elites adopting Islam with that generating adoption of Islam by lower classes (to be “in sync” with ruling classes); but it was not spread by Arab or Muslim military conquest as it was in so much of the Middle East. Prior to Islam in Indonesia religion there was a mix of local beliefs with some import of Bhuddism and Hindu beliefs; and Islam there contains some ad mixture of those beliefs, just as Islam in Iran did not eradicate Zoroastrianism within it.
Further thoughts on Hair, sanitation, and religion.
Discovery of germs in the 19th Century must have influenced customs including hair length, thus differences before and after the Civil War. Lack of fuel in desert areas probably influenced Jewish dietary and subsequently Muslim dietary laws. Pork and seafood were especially vulnerable to parasites and microbes. Mohamed was especially concerned with healthy practices. Praying 5 times a day required hand washing. Using the right hand for the communal food pot, and the left hand for toilet functions. This in particular meant cutting off the right hand was mostly a death sentence as it blocked much food access. Hair cover by scarves or turbines reduced picking up vermin from other people.
Business travel to far countries meant spending time to find product, arrange for transport and storage, and wait for shipping to be ready or available. Mosques became necessary in such business centers to keep the faithful maintaining their health preserving practices and the FAITH. One little known influence was that of Islam in Yemen. There was a concentration of the faithful there and after the Hajj, some Muslims went to Yemen for consultation and planning to spread the faith. After the great Krakatoa eruption (1883) in Indonesia, Muslim activists with Yemen connections urged the population to get rid of Dutch colonial rule, since they had lost the “mandate of heaven” for this rule. (Simon Winchester book reference, from memory)