Within a mobile website, there is a JavaScript snippet that appears as follows:
<script type="text/javascript">
(function() {
// actual function code is not shown here
}());
</script>
Upon initial page load, the code is successfully executed. However, if the user navigates back to the previous page and then returns to this page, the code fails to execute a second time. This behavior is only observed when the page is accessed using an older Android browser with the following User-Agent header:
Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; GT-S5570 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
In contrast, on a more recent Android device with the following User-Agent header:
Mozilla/5.0 (Linux; Android 4.2.1; Galaxy Nexus Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
the code successfully executes every time the page is loaded. Is this a known issue specific to the older browser in use? As a side note, what is the distinction between the following code snippets:
(function() {
// function body omitted
}());
and
function() {
// function body omitted
}();