MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Check to see if file (ex. custom.css) exists before trying to load it.

    Feature Requests
    loading css error feature bug
    1
    1
    1125
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stanchan last edited by

      I, like (I assume) many of RPi tinkerers and hackers, make code changes on my desktop or laptop and then use git to push new code to the RPi. Since MagicMirror doesn’t track css/custom.css, the mirror fails to load up if the file is missing.

      I tried to come up with a PR to have the loader.js file check if the file exists before appending it to index.html. However, since this is client side JavaScript, it does not have access to the file system and can’t use the fs JavaScript module.

      I then tried to use code like:

      	var fileDoesNotExist= function(url) {
      		var http = new XMLHttpRequest();
      		http.open("HEAD", url, false);
      		http.send();
      		return http.status==404;
      	}
      

      to do an http request to the server for the file, but realized that it’s just as bad as the actual http request that tries to load the file and will result in the same errors.

      So, I’m posting this here in case anyone has ideas and can help me with creating a PR to solve this problem. It’s not really a bug and not really a feature. Just an error check that’s missing.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy