I have a library that runs in a (function() { ... }) ();
scheme ...
// mylibrary.js
(function() {
function myfunc() { alert('hello'); };
if (...)
return;
// do something
}) ();
... that I use in a HTML page :
<!DOCTYPE html>
<html lang="en">
<body>
<div>Bonjour</div>
<script src="mylibrary.js"></script>
<script>
myfunc(); // scope error !
</script>
</body>
</html>
How to call the function myfunc()
outside the library ?
Should I change the (function() { ... }) ();
scheme ? (that I used to be able to do some return
inside the library)
What is the most common practice?