How the java script is loaded in QML file?
-
If we include same javascript file in multiple QML documents then whether it will get loaded multiple times ?
example:
'''
//----customButton.qml---
import "common.js" as commonObj
Item{
....
}//----customLabel.qml-----
import "common.js" as commonObj
Item{
....
}
'''
Whether importing same JS file in multiple QML files gives any hit on loading time of QML. -
If we include same javascript file in multiple QML documents then whether it will get loaded multiple times ?
example:
'''
//----customButton.qml---
import "common.js" as commonObj
Item{
....
}//----customLabel.qml-----
import "common.js" as commonObj
Item{
....
}
'''
Whether importing same JS file in multiple QML files gives any hit on loading time of QML.Hi @RamK,
If we include same javascript file in multiple QML documents then whether it will get loaded multiple times ?
AFAIK, Yes. It's documented:
Most JavaScript files imported into a QML document are stateful implementations for the QML document importing them. In these cases, each instance of the QML object type defined in the document requires a separate copy of the JavaScript objects and state in order to behave correctly.
The performance hit will depend upon the size of JS ofcourse.
An alternative is to use shared library.
Find more info here.