If they used a variable outside of IIFE, this could interfere with the variables of 10,000 human javascript on 10,000 human web pages. If there was already a variable with the same name, their inclusion on the page could interfere with work, and people would say: "I tried to use Twitter, but it broke my web page." Whether true or not.
Doing this the way they did leaves as little impact on the surrounding code as possible.
Variable inside
If they put the variable inside, it would be harder to document what should be added to an already working web page. They would need to teach the new javascript user how to format string variables, and the new guys would have to enter their information in two places in the code.
Thus, they should show only all lines, and the last - as "magic". βCopy these lines into,β they say.
They then explain that you must put the names of two things in quotation marks on the last line. It is easier to explain.
Admittedly, this is not much easier. But itβs a little easier to explain the times when thousands of people using it could increase market penetration, so to speak.
source share