Announcement

Collapse
No announcement yet.

How to load an external library before interface loads?

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

  • How to load an external library before interface loads?

    I see there is a Espo.loadLib function, but it does not seem to work. Say that I want to load this js: http://yourjavascript.com/31429113014/x.js
    If I host the file myself it seems to work Espo.loadLib('x.js',function(){console.log('loaded ');}); but putting the whole url does not work, but that is not a big deal.

    Yet I don't think that loading libraries in a view is the best design because of the delay each time. How can I load a library along with the others normally loaded by espo before the interface loads?
    Last edited by tothewine; 01-31-2019, 09:55 PM.

  • #2
    After some fiddling, here is a partial solution: After defining a new library in /custom/Espo/Custom/Resources/metadata/app/jsLibs.json file (no __APPEND__ needed) in custom view we do...
    Espo.define('custom:views/fields/iframe', ['views/fields/text', 'lib!MyLibrary'], function (Dep) { // view... }

    The only downside is that I wasn't able to get my library to be preemptively loaded in the pre-load.json file.
    Last edited by tothewine; 01-31-2019, 09:57 PM.

    Comment

    Working...
    X