People tend to associate intelligence with brain size. And as a general rule, it makes sense: the more brain cells, the stronger the intelligence. Humans and many other animals we think are unusually intelligent, such as chimpanzees and dolphins, have brains. For a long time, it was thought that the smallest brain simply did not have the ability to support complex mental processes.
Now researchers think that "cognitive" behaviors, rather than automatic responses, may be fairly common in spiders. A research paper on spider diversity published in the 2021 Entomological Annual Review shows that weavers who adjust the way they knot their webs based on the type of prey they catch, to ghost spiders who are able to learn to associate rewards with vanilla smells, have more things happening in their brains than they normally get.

The researchers' work suggests that if spiders' abilities are manifested by animals with much larger brains, such as dogs or human toddlers, we would not hesitate to see them as a sign of intelligence. One possible reason spiders are so advanced in behavior is that they possess the sharpest vision known to animals of the same size, and they use this visual ability to find, track, and pounce on their prey, rather than adopting the more famous spider strategy of building a web and waiting for food to arrive.
The spider's vision frees them up and allows them to explore an environment where they need to be able to see things from a distance, predators, prey, mates, and make decisions before approaching them, which is what causes them to have fairly good cognitive abilities. The researchers found a clear relationship between the time the spider spent surveying the route and the likelihood of choosing a safe path, and the researchers believed that the spider's observation was thinking, spending more time observing the route before making a decision.