Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How the java script is loaded in QML file?

How the java script is loaded in QML file?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 675 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RamK
    wrote on 1 Jun 2015, 09:18 last edited by
    #1

    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.

    P 1 Reply Last reply 1 Jun 2015, 09:30
    0
    • R RamK
      1 Jun 2015, 09:18

      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.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 1 Jun 2015, 09:30 last edited by
      #2

      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.

      157

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RamK
        wrote on 1 Jun 2015, 09:41 last edited by
        #3

        Thank you , given link is helpful.

        1 Reply Last reply
        0

        1/3

        1 Jun 2015, 09:18

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved