Forum - Primo: How to use multiple JavaScript files?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #35250
    Anonymous
    Inactive

    I’m new to Primo and want to know that how can I include multiple JavaScript files in Primo? For eg. custom.js and custom2.js. If that’s possible, where can I include the js filename through Primo Admin Panel or any other possible way.

    #36870
    Anonymous
    Inactive

    Dont think by default you can. But you may include/import if needed.

    Primo only looks at and use custom.js.

    However, if you are using the Primo development environment, you can split your js into separate files. When you run gulp, it will merge all js files found under the js folder (excluding subdirectores) into one custom.js file. Rest of them will remain intacted. If you want to include addtional js files to be used, you can create a subfolder inside the js folder and put them in there. They will not be merged into custom.js.

    Cheers,
    Kevin

    #39787
    Solent University 44SSU_INST
    Participant

    I haven’t been able to get import to work. Is there anyone who has done this who can share their code?

    #47649
    Paul Madley
    Participant

    I can’t recall where I got this from, or who AFD is, other than part of the WHELF consortium. Which I’ll address before we go live. Anyhoo…

    /**Load the Javascript file used for the rotating images on the Primo home page – AFD 29-08-2018**/
    var s = document.createElement(‘script’);
    s.id = ‘localScript’;
    s.src = ‘THE URL OF YOUR CODE HERE’;
    document.body.appendChild(s);

    #47650
    Paul Madley
    Participant

    As Kevin says though, Gulp will get involved and try to put the files together in the dev environment. We use SVN so I simply remove the offending file (custom.js) and then do an SVN update. This is on our own dedicated dev server btw.

    #53276
    Wai-yan NG (The Open University of Hong Kong)
    Participant

    Try this:

    app.controller(‘someController’, [‘angularLoad’, function (angularLoad) {
    angularLoad.loadScript(‘/primo-explore/custom/vid/js/another.js’);
    }]);

    #62662
    Antrez R
    Participant

    Hi,
    would you have an example of running/calling JS function into custom.js? Set any time out?

    • This reply was modified 6 months, 4 weeks ago by Antrez R.
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.