Edited
How you're going to achieve this is going to depend on the script object's scope.
Search in the scripts file for the function executed when the window is loaded. It should begin with either:
window.onload = function...
or
window.addEventListener("load"...
The contents of this function will depend entirely on how the template devs coded the script, so I can only give you rough guidelines from here.
You need to find out the name of the script's main container object. It's probably called something like 'themeForest'. You're looking out for something like:
var themeForest = new ThemeForest
or (as is likely, it's been built using a JS package manager) maybe something like:
var themeForest = __webpack_require__(391);
Exact implementation will differ.
Now, you want that object to be available in global scope. So, using the above examples, they'd look like this:
var themeForest = window.themeForest = new ThemeForest
or
var themeForest = window.themeForest = __webpack_require__(391);
The important bit is making sure that the script is made into a property of the window object. If window.themeForest
is there already then great, it's already available in global scope. If not add it like I've done above.
Now you should be able to override any individual methods, functions and variables by reassigning them in your override script. Let's say there's a method called init()
that you want to override. In your script add:
window.themeForest.init = function() {
// Function contents
}
Make sure your script is loaded in your template after the template's scripts.js file.
All other themeForest properties will stay as they were, but the init property will now be your function.
You might also want to add this at the top of your script to make redeclaring things a little quicker:
window.themeForest = themeForest
Now the override example I gave above would look like this:
themeForest.init = function() {
// Function contents
}
Hope that helps - I can't really give a more specific answer without knowing exactly how the template's script works I'm afraid.