To improve performance we could make autodetection work less when a language is already detected. We can use some sort of hit/miss logic when a call to the autodetect feature is not done if the last x calls returned the same result.
For example: If after 10 calls the result is "javascript" then we assume that for another 10 calls is still going to be "javascript". At the 10th call we check again.