Announcement

Collapse
No announcement yet.

Front-end libs : loading page by page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    You can load libs as modules https://docs.espocrm.com/development...a/app-js-libs/

    Comment


    • yuri
      yuri commented
      Editing a comment
      Note that this doc is actual as of v8.0.

  • #3
    Originally posted by yuri View Post
    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


    • #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.

      Comment

      Working...
      X