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
-
-
Show 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.
Show this thread
End of conversation
New conversation -
-
-
Isn't PIFE just a normal anon function that is hoisted?
-
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
- 1 more reply
New conversation -
-
-
PIFE - LOL! "P" for "pointless"?
-
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 more replies
New conversation -
-
-
Isn't the following pattern used as well? (function() { code }())
-
It is. We already make the decision when we see: (functionhttps://twitter.com/mathias/status/1118140391277117450 …
End of conversation
New conversation -
-
-
Interesting! Do you know if any browsers hash/memoize compilation of super common FEs like Google's famous `(function(i,s,o,g,r,a,m)...`? Or if it'd even be worth doing so?
-
V8 doesn’t special-case any particular function expressions in this way, no. We focus on optimizations that apply more generally, so that we don’t need to.
End of conversation
New conversation -
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.