Answer the question
In order to leave comments, you need to log in
Is it possible to substitute arbitrary data in custom js?
I have a script like this:
$(document).ready(function () {
let allVideo = new window.VPlayer('192.168.1.67');
/**
* function (number, port, canvas_element, container)
*/
allVideo.addVideo(0, 49002, $("#video-canvas-1").get(0), $('#jsmpeg1'));
allVideo.addVideo(1, 49004, $("#video-canvas-2").get(0), $('#jsmpeg2'));
allVideo.addVideo(2, 49006, $("#video-canvas-3").get(0), $('#jsmpeg3'));
allVideo.addVideo(3, 49008, $("#video-canvas-4").get(0), $('#jsmpeg4'));
});
Answer the question
In order to leave comments, you need to log in
You are overthinking. Any template engine will help you - treat this file as a text file.
Env variables are now often used to configure JS on build.
further before assembly, SERVER_URL is set to the desired value in one of a ton of ways (this is a real environment variable) - at the output you get a js file with a substituted string.
It's comfortable and super flexible.
a common practice when building with webpack, I don’t know if gulp can do this, but I’m willing to bet that yes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question