I have a small parser on php, it "does everything it needs to do" with the code and sends the finished file to the user.


Is it possible to make the interpretation of the code already on the front end?
And the main question, in fact, is how to make js read the css file and after processing apply all the code to the site ...

  • Why do you need to sass on the frontend? - ishidex2
  • It is not very clear what exactly you want to do - “file to user” - to such a user, who is he and why does he need the file? "Interpretation" - what does this mean for you in this context and what does "front end" mean in it? - Stanislav Belichenko

1 answer 1

For sass this is not necessary, usually ... but, yes it is possible, there is a javascript library https://github.com/medialize/sass.js/ , you can start here https://github.com/medialize/sass .js / blob / master / docs / getting-started.md

You can embed <link > , <style> tags, or influence DOM elements to apply styles; these are standard JavaScript features.

It must be remembered that compiling sass is a resource-intensive operation. If the application is small and not loaded, for some reason and no. Tasks in real life are different.

 <script src="dist/sass.js"></script> <script> var scss = '$someVar: 123px; .some-selector { width: $someVar; }'; sass.compile(scss, function(result) { console.log(result); }); </script> 
  • Hmm .. As I did not immediately think of using <style>. No, I better use my version, I don’t need all sass, it’s too heavy, and I strive for minimal traffic. - Michael