Was snooping the dependents graph and spotted an interesting tweak in the wild:
// Single substring check — "youtu" covers both youtube.com/watch and youtu.be/
// Avoids scanning large HTML twice (was two includes() calls on 15-50KB per page)
if (!content.includes("youtu")) {
return content;
}
In other words, it does a quick initial check for just youtu and only proceeds with the full regex if it's present. I'm genuinely unsure of the performance gains you'd get from this but it's worth trying to do some actual benchmarking.
(Also includes the comment // Catches bare YouTube links in Markdown that the embed plugin misses — @rmdes if this is something that we can fix upstream, happy to discuss!)
Was snooping the dependents graph and spotted an interesting tweak in the wild:
In other words, it does a quick initial check for just
youtuand only proceeds with the full regex if it's present. I'm genuinely unsure of the performance gains you'd get from this but it's worth trying to do some actual benchmarking.(Also includes the comment
// Catches bare YouTube links in Markdown that the embed plugin misses— @rmdes if this is something that we can fix upstream, happy to discuss!)