adding and using library



  • using this as example:
    <head>
    <script src="jquery-1.12.0.min.js"></script>
    </head>

    To add any library to nodebb do I just paste in custom header?
    Also where do I put the library file(s)?
    What is path that need to be use for url to reference it?



  • Does anyone know of any nodebb doc that describes how to do this?
    Is adding a library to nodebb manually not recommended?


  • Gamers

    I think you can use the cdn of jquery if you want.



  • @Nisthar yes can use cdn. right now trying to learn and understand how to add any library.

    another example:
    foundation site shows this in head
    <link rel="stylesheet" href="css/foundation.css" />

    and this before the closing body
    <script src="js/foundation.min.js"></script>

    that part I understand for standard html file by creating the css and js folder and including the files but I want to do that inside nodebb.

    Where do I put the css and js file for any library so it can be referenced and use for nodebb?

    Not sure if I'm giving right details. Hope that make sense


  • Community Rep

    Hey @charles, unfortunately, there's not one solution that will work for every library.

    Many libraries will work just by adding the <script> tag alone to your Custom Header section of the ACP. But some are picky about in what order they get loaded, some won't work at all (without some help), and some will need you to use a require() call to load them. If we knew the specific library/s, I think we could be of more help.

    As far as uploading the library, everything in the /public directory is exposed on the website root. So, you can generally put the library anywhere in there.


  • Community Rep

    Just saw you posted about foundation.

    foundation should work by adding the <script> tag, but you'll also need to reload it whenever the page changes, like so:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.0/foundation.min.js"></script>
    <script>
    $(window).on('action:ajaxify.end', function(){
        $(document).foundation();
    });
    </script>
    


  • @yariplus said:

    As far as uploading the library, everything in the /public directory is exposed on the website root. So, you can generally put the library anywhere in there.

    This is what I was looking for! Thanks!

    As for loading a js file at the end right before the closing body, which file should I place the script tag?


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.