and import it into a qml file. For example:
import "factorial.js" as MathFunctions
I spent a lot of time trying to answer that question: I think the answer is "No".
There are workarounds (check Google).
An obvious one should be to instead import a QML file that imports a JS file. Then stack these to create as many layers as needed. Though I don't think it is recommended.
We had similar situation with QtScript, but there you can use scriptextensions to simulate such functionality. We have a lot of application logic in scripts, so it helped us. But such way is impossible now in qml, because scriptengine used by qml is private member and can't be accessed from your code. And I also don't know other ways to solve it.
I faced a similar situation. The only solution I found was to create a separate qml file and import all the JS files there.
Btw , it will be nice if it will be an import_once feature in QML.
Actually, it is possible. All you need is to call
I'm certain this used to be in the docs. I've filed http://bugreports.qt.nokia.com/browse/QTBUG-15855 so the docs get fixed.