关于script标签非标准type属性含义与作用的技术问询
script Type Attributes? Awesome question—this is a super common trick you’ll spot on modern websites, so let’s break down exactly what’s going on here:
First off, values like type="02aa3743b2e6c0a724cb116b-text/javascript" are non-standard, custom type values—they’re not recognized by browsers as valid executable script types (unlike the standard text/javascript, which is even optional in modern HTML). Their purpose almost always ties to website resource protection or conditional loading logic, and here’s the breakdown:
Anti-scraping/automation protection
This is the most common use case. Generic web crawlers and scrapers are programmed to look for scripts with standardtext/javascripttypes to extract or execute. By adding a random, unique prefix to the type value, sites make these scripts invisible to basic crawlers. Meanwhile, the site’s own legitimate frontend code (usually a separate, standard script) will dynamically replace this custom type with the standardtext/javascriptlater on—so real browsers will still run the code normally, but scrapers get blocked.Delayed or conditional script execution
Browsers only execute scripts with a recognized executable type. A script with this custom type gets treated as a plain DOM node (like a data block) instead of runnable code. Sites use this to hold off on executing certain scripts until a specific condition is met—for example, after the page finishes loading, when a user clicks a button, or when a required resource is ready. Once the condition is satisfied, a small JS snippet updates the script’stypeattribute to the standard value, triggering execution.Internal resource tagging (rare)
Occasionally, the random string acts as an internal identifier for the site’s own resource loader. It helps categorize scripts (e.g., third-party analytics, dynamic content rendering, core business logic) so the loader can process each type appropriately. That said, this is far less common than the anti-scraping use case.
The core trick here is leveraging browser behavior: if a script’s type isn’t a known executable MIME type, the browser ignores it until something else tells it to run the code.
内容的提问来源于stack exchange,提问作者kevin mayank




