Skip to content

Audit possible performance improvements from bailing early in absence of youtu #393

@gfscott

Description

@gfscott

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!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions