Make extensions optional in JS

In the changes you made in response to issue #1, inputs without specified extensions would crash, even though the "extensions" option in the API is optional. This checks to see if any are specified before trying to fetch them.