Front-end libs : loading page by page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firyo
    Senior Member
    • Jun 2022
    • 135

    Front-end libs : loading page by page

    Hi there,

    After developping and maintaining my extensions for quite a while, adding new features.
    Some of these features required me to use external front-end libs like Datatable, sweetalert2...

    Some of these ones are required to be loaded on everypage (like sweetalert2) but some other ones aren't.

    I currently am loading all these libs in the https://docs.espocrm.com/development...ta/app-client/ file of my extension.
    This makes the user load all the libs each time we render the SPA.

    Is there a way in EspoCRM to individually load these kind of libs page by page.
    Like :
    I want to load the lib X with these CSS and JS files on the pages :
    TestEntity/detail
    myCustomPage22


    Regards,
    Firyo.
  • yuri
    Member
    • Mar 2014
    • 8627

    #2
    You can load libs as modules https://docs.espocrm.com/development...a/app-js-libs/
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • yuri
      yuri commented
      Editing a comment
      Note that this doc is actual as of v8.0.
  • Firyo
    Senior Member
    • Jun 2022
    • 135

    #3
    Originally posted by yuri
    Okay that looks good to me but what if I have like multiple files for a particular lib ?
    Does the "path" and / or "devPath" properties could be an array instead of a string (I see in the doc that they are both strings but like in the future) ?

    Regards,
    Firyo.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8627

      #4
      No. They cannot be arrays. Every item is a JS module. JS module cannot be defined in multiple files. You need either multiple modules and require each of them depending what you use. Or you need to bundle your library into one module (likely, you won't need it as usually libs shipped in UMD which is supported). It's more JS specific question. JS modules is a complex subject to comprehend.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      Working...