Read the statement by Michael Teeuw here.
What is the difference between require() and getScripts()?
-
I’ve been trying to implement the jquery dependent package (
Tabulator
) on my mirror. What it does is, convert JSON data into a nice dynamic HTML table.In the working HTML version, I just the
script
tag, to include everything, but in a Node MMM, we can either userequire("blablah")
in thenode_helper.js
file, or usegetScripts("blablah.js")
in theMMM-MyModule.js
file.- What is the difference?
- When to use what?
Right now I’m using the 2nd option, and it loads, but the table is never shown… I’m thinking I’m missing something.
-
require()
is for when you mean “I’m going to use this code somewhere else in this script I am writing right now” — i.e. somewhere on the server-side.getScripts()
is for when you mean “my client-facing/browser code will need this loaded to perform some operation” — i.e. somewhere on the client-side.(As always, this is what I understand and hope someone will correct me if I’m wrong.)
-
@ninjabreadman Aah! Finally. Thank you. That is the most sensible explanation I’ve seen.
(If you’re a moderator, please mark this as closed/solved.) -
Well you really shouldn’t mark this as closed or solved because I’m sure others will have questions too :)
It’s a GREAT explanation… and it’s also a GREAT question!!! I’m sure others have wondered and I know people don’t usually ask for fear they’ll look ‘not smart’…but NO question is a dumb question!!
The worst question in history? The one that never got asked! :)
-
@cowboysdude said in What is the difference between require() and getScripts()?:
I know people don’t usually ask for fear they’ll look ‘not smart’
I don’t have this problem. ;-)
-
@Mykle1 said in What is the difference between require() and getScripts()?:
@cowboysdude said in What is the difference between require() and getScripts()?:
I know people don’t usually ask for fear they’ll look ‘not smart’
I don’t have this problem. ;-)
Which one? Asking or not being smart LOL
-
Both? ;-)