Gensoki
Gensoki

Reputation: 133

Error when trying to use LESS on file://

When I try to use my LESS file on google chrome it brings up this error on console:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
less.js:446 XMLHttpRequest cannot load file:///path/core.less. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

I have downloaded the less.js and put it in the script tags as seen below

head class="Setup">
    <!-- LESS -->
    <link rel="stylesheet/less" type="text/css" href="path/core.less"/>
    <script src="path/less.js" type="text/javascript"></script>

However if I use a package for my text editor, namely https://atom.io/packages/browser-plus it works fine. Console logs:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
less.js:837 rendered file:///path/core.less successfully.
less.js:837 css for file:///path/core.less generated in 67ms
less.js:837 less has finished. css generated in 67ms

After checking the Google Chrome versions, the text editor uses Version 47 whereas my normal chrome is on Version 50. I have no idea what's happening. Is there a fix for this?

EDIT: Found less.js not working in chrome Since I don't know how to setup Apache I tried searching up how to create command-line switches brought up windows results whereas I'm using a mac.

Upvotes: 0

Views: 394

Answers (1)

BenM
BenM

Reputation: 53198

As you've correctly identified, LESS.js won't work with the file:// URL scheme in Chrome:

P.S.S. Less.js browser script currently won’t work if you’re using Chrome and the path to your page starts with “file:///” due to a known Chrome issue.

Since you're running Mac OSX, I'd advise installing MAMP, since it takes the headache out of setting up a local server for you:

https://www.mamp.info/en/

Upvotes: 1

Related Questions