(This is a follow-up question from here.)
From the Metamask developers faq it is stated to "bundle the version of web3 that is used during development".
So I downloaded a web3.min.js version 0.20.6 from GitHub and "bundled" it like in the code below. Then I log "web3.version.api" to the console.
Now, with or without the bundling, the console reports a version 0.20.3 after clicking the button.
I suspect this is due to the line
web3 = new Web3(web3.currentProvider);
which sets web3 to the injected code from my Metamask plugin, in which I am logged in, and it runs that code, not my "bundled" version ...
Question: How do I bundle my own version of web3?
<html>
<body>
<script type="text/javascript" src="scripts/web3.min.js"></script>
<script type="text/javascript">
window.addEventListener("load", function() {
if (typeof web3 === "undefined") {
console.log("No web3 provider found");
} else {
web3 = new Web3(web3.currentProvider);
console.log("Using web wallet");
}
}) </script>
<button id="buttonBalance">Click to report version to console</button>
<script type="text/javascript">
button = document.getElementById("buttonBalance")
button.onclick = function tmp()
{
console.log("Version=" + web3.version.api);
};
</script>
</body>
</html>
PS. I created the button to make sure the web3 call to "web.version.api" is done "outside adding the eventListener to window" as per the suggestion of @Kai Kälberer
Update: As suggested by @viz I downloaded the non-minified web3j version from GitHub and uncommented the line that avoids overriding the global web3 instance. Check this screenshot from my dev tools debugger:
Still I see that the console prints out the version 0.20.3 and not 0.20.6 as defined in the downloaded web3.js ... why?
Web3
object.