The official elasticsearch guide says: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html
Store and retrieve scripts You can store and retrieve scripts from the cluster state using the stored script APIs. Stored scripts reduce compilation time and make searches faster.
How do stored scripts reduce compilation time and make searches faster compared to inline scripts?