Why Nostr? What is Njump?
2023-03-12 21:53:17
in reply to

aritter on Nostr: It was just a very simple getting https requests from the browser vs sending ws ...

It was just a very simple getting https requests from the browser vs sending ws messages, and WebSocket / Nostr won by 10x. Maybe working more on HTTP/3.0 support would speed things up and allow better caching, but it's probably just not worth it, as it's getting farther from the original Nostr protocol:

w=new WebSocket("wss://rbr.bio"); w.onopen=()=>console.log("opened"); w.onmessage=(x)=>console.log("message", x)
z=0;all=1000;time=Date.now();w.onmessage=(x)=>{if(JSON.parse(x.data)[0]=="EVENT") z++; if(z==all) console.log("time",Date.now()-time) }; for(i=0;i<all;i++) w.send('["REQ","1",{"authors":["82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2"],"kinds":[0]}]')
// 2500ms
let u="https://rbr.bio/82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2/metadata.json";
time=Date.now(); a=[];for(i=0; i<1000; i++) a.push(fetch(u)); for(i=0; i<a.length; i++) await a[i]; console.log(Date.now()-time)
// 21035ms

Also tested JSON.parse:
time=Date.now();for(i=0; i<1000; i++) JSON.parse(data);Date.now()-time
// 2ms
Author Public Key
npub1dcl4zejwr8sg9h6jzl75fy4mj6g8gpdqkfczseca6lef0d5gvzxqvux5ey