p5.js Game dev | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

p5.js Game dev

I want to use p5.js in a particular script tag not at all code . What should i do i thought i should use p5.js url at href attribute would it work or i should put it at src attribute😨 plz help

18th Jun 2020, 9:57 AM
Priyanshu Gupta(प्रियांशु गुप्ता)
Priyanshu Gupta(प्रियांशु गुप्ता) - avatar
2 Answers
+ 1
each script tags of a same html document share the same global environnement, so you cannot limit the "use p5.js in a particular script tag not at all code"... however, that should not be a problem until you doesn't override p5.js global variable(s): you just have to use it where you want and don't care of it where you not want (in the limit of previous warning, obviously ^^) anyway, script tag have only src attribute (not href), so the only way to link it is by the src attribute of an EMPTY script tag (without code inside: browsers ignore js code inside script tags if there's an src url provided, and only execute the external linked js file)
18th Jun 2020, 12:33 PM
visph
visph - avatar
0
The soln is not to use p5.js
17th Aug 2020, 2:33 AM
Priyanshu Gupta(प्रियांशु गुप्ता)
Priyanshu Gupta(प्रियांशु गुप्ता) - avatar