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
-
Imagine you’re a JavaScript parser, and you have to decide whether or not to eagerly parse+compile after ONLY having seen this part of the code (and nothing else): (function …or… !function
1 reply 2 retweets 19 likesShow this thread -
It seems reasonable to assume that this is an IIFE, and that this function will be immediately invoked. But we don’t know for sure — it might *not* be an IIFE. That’s why calling them IIFEs would be imprecise. “PIFE” makes this distinction.
2 replies 2 retweets 13 likesShow this thread -
Replying to @mathias
There's a dance here, and an unusual one at that. Rather than inference, is there any mileage for, say, declarative prioritization? I ask because whenever an engine infers it makes the implementation details canonical & generates received "wisdom". Like translateZ.
2 replies 0 retweets 3 likes
…and like optimize-js, which is mentioned in the blog post.
We’re in agreement. Developers shouldn’t optimize for any particular implementation heuristic (which might change at any point in time!).
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.