Developer Docs
Discover how to get the most out of Divhunt for your unique needs, and explore the possibilities of building plugins to make Divhunt a better tool for everyone.
With Divhunt's system, you can add third-party libraries and use them when needed. You can load multiple CSS and JS files under one ID. When you need these library, just one call makes everything ready for you.
Add Library
Using code below, you can add specific library to module mdLibraries.
mdLibraries.ItemAdd({
id: 'library_id',
css: ['https://cdn.com/example.css', 'https://cdn.com/example2.css'],
js: ['https://cdn.com/example.css', 'https://cdn.com/example2.js'],
});Load Library
After adding a library to our module, if a part of our code needs that library, we can just use the code shown below. This makes sure the library is loaded. We can check for several libraries at the same time as in the example. If the library is already loaded, our code will run without loading the library again.
mdLibraries.Fn('load', ['library_id', 'library_id_2'], () => {
console.log("Here I am sure that both 'library_id' and 'library_id_2' are loaded and ready to be used.");
});View Existing Libraries
If you forget what libraries you've added to the mdLibraries module, or if you want to check their names, simply use the console.log code shown below. This will display all the libraries available to you, along with details about each one.
console.log( mdLibraries.ItemsGet() );Table of content