I have a code snippet to include in a project, and I'd like to know if there's a purpose to why it was written like this or if I should clean it up. Is there an optimization trick I don't know about?
Here's the (sanitized) code snippet. Notice a,b,c,d passed in and then assigned in the function.
(function (a, b, c, d) {
a = '//url/to/js/file.js';
b = document; c = 'script'; d = b.createElement(c); d.src = a; d.type = 'text/java' + c; d.async = true;
a = b.getElementsByTagName(c)[0]; a.parentNode.insertBefore(d, a);
})();
I found this answer after writing this question up. Is that the only reason?
That way you can make a local scoped variable without explicitly declaring it using var
statement.
IIRC it's commonly used by code minifiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With