You make a message object? by push the data "message" and its timing into an array, performance now is the highresolution timer in Javascript..
Notice there is no PPQ or resolution involved, if you want that you will have to quantize it yourself.
midiMess: [];
browserLoadTIME=0;
rs = document.getElementById("recstart"

.value;
function startRecord(){
startTIME=performance.now();
}
function onMIDIMessage(message) {
record(message);
}
function record(message) {
clock = performance.now()-startTIME+rs;
track[rectrack].midiMess.push({
time: clock,
data0: message.data[0],
data1: message.data[1],
data2: message.data[2]
});
}
In the URL below is my midisequenser in vanilla Javascript i do have problem with lag during playup that i somehow need to resolve.