Multiple html pages and CSS sketch with editor.p5js.org

I did some experiments on your p5.js Web Editor mini-site and these are my discoveries about it: :male_detective:

  • As you already told us the 1st entry page is working as it should.
  • However if we open the browser’s console and go to its “Network” tab we won’t spot the file named “styles.css” being loaded there:
    editor.p5js.org/bardyl/sketches/J4ZS_c853/styles.css
  • Instead if we go to “Elements” tab we’ll find the CSS file’s content inside the HTML file at tag <style> inside tag <head>.
  • Now clicking at any of those 6 links we’ll get pages w/o any CSS style applied.
  • Starting by going to “Console” tab we’ll see the following warning logged:
    Resource interpreted as Stylesheet but transferred with MIME type text/html:
  • Going back to “Elements” tab we can spot the following <link> tag inside <head>:
    <link rel="stylesheet" href="styles.css" type="text/css">
  • That didn’t exist on the the 1st entry page which uses a <style> tag instead.
  • Investigating it further I went to “Network” tab and clicked at the loaded “styles.css” entry.
  • On the 1st tab “Headers” at “Response Headers” I see:
    content-type: text/html; charset=utf-8
  • But at “Request Headers” I’ve got:
    accept: text/css,/;q=0.1
  • That means the <link> tag requests a file of type “text/css” but the server editor.p5js.org returns a “text/html” type instead!
  • So it’s not your HTML files which are buggy but editor.p5js.org itself doesn’t know how to serve CSS file requests using the proper “text/css” type!
  • Instead that online editor resorts on transferring the content of CSS files to its HTML file inside <style> tags as a workaround!
  • But that hack fails for the other HTML files linked by the main HTML!
  • You may try to bring this glitch to their attention by going here:
4 Likes