Terminology:
IIFE: (function() { code })()
PIFE: (function() { code })
Since IIFE detection would be too slow, JavaScript engines detect PIFEs to decide whether to eagerly parse + compile functions that are needed, boosting startup times.
https://v8.dev/blog/preparser
-
Show this thread
-
-
Replying to @tjcrowder
Think of it as one of these:
Possibly-Invoked Function Expressions
Profile-Informed Function Expressions
Note that all IIFEs are also PIFEs, but not the other way around. They’re not usually “pointless”.2 replies 0 retweets 15 likes -
Replying to @mathias
Ah, okay. The example was (no reference saved, so the function couldn't be called), so I wondered if it was a joke.
1 reply 0 retweets 1 like
The article explains it in more detail; it’s all about looking at it from the perspective of a JS parser. You just don’t know whether the function expression is immediately invoked until you parse all the way to the end, which is costly. We need a simpler heuristic, thus: PIFEs.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.