(Original FAQ by eighthjouster. Contributions welcome.)
- What is JSCause?
- What does JSCause mean?
- What can I use JSCause for?
- Why would I use JSCause? Aren’t there better tools for its intended use?
- Is JSCause a toy or a joke application?
- Can I use JSCause on Windows/macOS/OS X/Linux?
- Is JCause ready for production?
- Is JSCause secure/safe to use?
- How fast is JSCause?
- Can I use databases with JSCause?
- Can JSCause handle Ajax requests?
- Can I use Node modules with JSCause?
- Can JSCause work with React/Vue/my favorite front-end framework?
- Does JSCause support Typescript?
- Does JSCause support Webassembly?
- How does JSCause compare with other frameworks like Express?
- Why does the browser complain about security when accessing a JSCause site during development?
- Why doesn’t JSCause complain when a certificate or key file is invalid?
site.json
accepts a hostName that could already be used in another site’s json. Is this a bug?- JSCause says a file does not exist, but I can see it in the file system. Why?
- Isn’t the idea of JSCause a dumb one?
- Did you ever stop to think whether you should do this project just because you could?
- Do you like Javascript? Are you a masochist?
- Are you trying to replace PHP as the worst backend language ever?
- How can you sleep at night?
- Should I keep reading this silly FAQ?
- My question is not answered here. How can I get help?
- How can I contribute to JSCause?
What is JSCause?
It’s a NodeJS application framework intended for building simple dynamic websites using Javascript on the server side.
What does JSCause mean?
It doesn’t mean anything deep. It’s just “Javascript Cause”, pronounced J-S-Cause. Our “Cause” is to bring back the joy of coding in Javascript without the need of complicated setups. Node and JSCause is all you need. No NPM, no Webpack (unless you want to), no Express, and no complicated configurations.
What can I use JSCause for?
JSCause is intended to for developers who want to build simple websites with some dynamic features (e.g. quizzes, small blogs, text-based games) and who also like the idea of using Javascript on the server side (as opposed to, say Java, PHP, Python, Perl, Ruby, etc.)
It’s also the gateway to NodeJS applications. Perhaps you don’t know much about NodeJS. JSCause allows you to dip your toes in the water.
Why would I use JSCause? Aren’t there better tools for its intended use?
For a static site, you could just use Apache and Nginx. But as soon as you need something dynamic content, then configuring these can be kind of involved (though admittedly you just have to do it once.)
For complex sites, other languages and tools can be more appropiate - say, Java, Perl, PHP or Ruby. Or even NodeJS, with Express and NPM, Webpack, etc.
However, if you’re looking to build a simple website, then those solutions can be a bit overkill. JSCause is a nice bridge between both static, simple websites, and complex ones. You can start with a static site, and as soon as you’re ready to add some dynamic elements to it, you can just jump right in with minimal fuss.
Also, JSCause can be a great prototyping tool. Put something together quickly, then as soon as it picks up steam or proves its worth, use other tools in order to take it to the next level.
Finally, JSCause was design to be simple and fun to work with. If you want to tinker with making a website and want a tool that doesn’t get in the way, then JSCause is right for you!
Is JSCause a toy or a joke application?
JSCause started not as a joke, but more as a “what if?” project. It’s far from perfect, far from complete, so it can look as a toy compared to other more powerful tools. But it’s aimed to serve a purpose and to serve it well.
Can I use JSCause on Windows/macOS/OS X/Linux?
JSCause is available on any platform supported by NodeJS, including Windows, macOS and Linux.
Is JCause ready for production?
Not yet. When JSCause reaches version 1.0 then yes, it will be ready for production. But there are quite a lot of things to implement and fix in order to get there.
Versions prior to 1.0 of JSCause are intended for testing, and perhaps readying applications for when version 1.0 is available. Use at your own risk.
Is JSCause secure/safe to use?
When developing JSCause, we’ve put great care to avoid many forms of pitfalls and vulnerabilities. But we can’t guarantee that JSCause is bug-free, therefore we can’t guarantee that it won’t affect your system due to some hidden flaw its internal code. We will reassess this stance once we reach version 1.0.
How fast is JSCause?
JSCause runs on top of NodeJS, and programs written for it are precompiled when they start, just like any other NodeJS application. Since NodeJS uses a modern Javascript engine, one can say that a JSCause application can be quite fast. However, speed will ultimately depend on the type of application written, and the quality of the code.
Can I use databases with JSCause?
JSCause does not have a built-in mechanism to handle databases just yet. This will come in a future version (1.0 or earlier), which will primarily focus on MySQL/MariaDB. Meanwhile, feel free to use any of the available npm packages, such as mysql, mysql2 or mariadb.
Can JSCause handle Ajax requests?
Yes, it can. The easiest way to do it is by using JSON as a response via rt.printJSON()
. The documentation has more information about rt.printJSON()
, but here is an example:
rt.printJSON({ randomNumber: `${Math.random()}` });
Notice that multiple rt.printJSON()
in the same program will not output chained JSON objects. Only the last JSON object output will be sent as a response.
Another way would involve manually setting the Content-Type
header to application/json
, then composing the JSON content just like one would with HTML. For example:
<js rt.header('Content-Type', 'application/json'); /js>
{
"randomNumber": "<js= Math.random() /js>"
}
Here are two more ways involving the use rt.unsafePrint()
(however, this is not recommended - use this if you really know what you’re doing):
rt.header('Content-Type', 'application/json');
rt.unsafePrint('{"randomNumber": "' + Math.random() + '"}');
And:
rt.header('Content-Type', 'application/json');
rt.unsafePrint(JSON.stringify({ randomNumber: `${Math.random()}` }));
Can I use Node modules with JSCause?
Yes, you can.
Can JSCause work with React/Vue/my favorite front-end framework?
Yes, it can. Given that those frameworks’ files must be delivered to the browser, this can be done via JSCause.
Now, if you plan on using the frameworks’ built-in development web servers, you may need to tweak your development environment so it can coexist with JSCause.
Does JSCause support Typescript?
Not officially. We haven’t tried this yet, but it shouldn’t be too hard to incorporate the Typescript compiler into your workflow. As static front-end assets, JSCause should be able to serve the resulting compiled Javascript without issue.
As part of a JSCP
program, it may be tricky (or may not - again, we haven’t tried it yet.) Typescript doesn’t support the <js ... /js>
block notation, you may need to arrange your sources so that the Typescript code is isolated from the JSCP code.
Does JSCause support Webassembly?
Not officially. We haven’t tried using Webassembly with JSCause. But it shouldn’t be too difficult to deliver Webassembly binaries to the web browser as static resources with JSCause.
How does JSCause compare with other frameworks like Express?
JSCause is very early in the game, so we don’t have all the information for different comparison metrics.
In terms of performance, we haven’t run the numbers yet. You’re welcome to give it a try, though - and please share!
In terms of use cases, Express and other frameworks have a wide range of use cases, from the development of web applications, to API providers and, of course, regular web sites.
JSCause focuses on the easy development of simple websites. It can serve as a tool for rapid prototyping. It can be used as a web dev basics teaching tool. And of course, it can serve as a platform to develop basic websites with minimal fuss.
In order to use Express and similar frameworks, you must install NodeJS and be familiar with it. You must use npm. And you must learn how to use Express, which can have a bit of a learning curve, depending on your web development experience. Granted, many frameworks including Express allow you to serve static files, just like with JSCause. But it involves a bit of setting up.
With JSCause, in turn, you must install NodeJS, and you must install the JSCause package, which can be a simply as uncompressing a zip file somewhere in your computer’s file system. That’s it. You can use the example site provided with the JSCause package as a starting point.
In the end, we used Express above to illustrate a point as to why you may want to use JSCause (and to answer this question). But it may be that Express, and frameworks similar to it, may be the right tool for your project; especially if it involves complex specifications. Always strive to use the right tool for the job.
Why does the browser complain about security when accessing a JSCause site during development?
When accessing a JSCause site in a development environment via web, the browser may initially display a security warning message to the visitor before displaying the page. Depending on the browser, the message may say that there is a “Potential Security Risk Ahead” (like Firefox) or that “Your connection is not private” (like Chrome.) This is because the site is being accessed via HTTPS, and JSCause is using a self-signed SSL certificate when establishing the connection.
Modern browsers will always warn visitors when a website is using a self-signed SSL certificate. In a production environment, you must provide a certificate created by a Certificate Authority (such as Comodo/Sectigo, RapidSSL, Symantec, or the free LetsEncrypt.org.) Otherwise your visitors will get a warning, and rightly so.
In a development environment, though, the warning can be safely ignored and bypassed.
Learn about how to set up your SSL certificates in JSCause when configuring your website’s details in the documentation (namely, the httpsCertFile
and httpsKeyFile
configuration attributes.)
Why doesn’t JSCause complain when a certificate or key file is invalid?
You may have configured the site as HTTP, not HTTPS. When the site is configured as HTTP, JSCause will ignore these files.
If the site is indeed HTTPS, then another reason could be that it’s sharing the port with another, correctly configured HTTPS site. In this case, the browser will alert the end users about the misconfiguration.
site.json
accepts a hostName that could already be used in another site’s site.json. Is this a bug?
This is fine as long as both sites use different ports.
JSCause says a file does not exist, but I can see it in the file system. Why?
It may be a broken symlink that doesn’t point to a valid file anymore. Also, check the spelling and the case-sensitivity. For example, if your file is named newPage.jscp
, make sure you’re typing it as is in the web client; NEWPAGE.JSCP
, newpage.jscp
, NewPage.jscp
, etc, won’t work.
Also, for now, whenever you add a new file, or rename/move it, restart JSCause so it picks it up. And make sure that it’s stored inside the website
directory.
Isn’t the idea of JSCause a dumb one?
Oh, because it’s Javascript? Look, JSCause was born out of a specific necessity. A lot of people complain about how web development has become this weird mess of libraries, configuring tools, building tools, minifiers, and loaders.
A lot of other people are trying to tackle this issue in different ways. JSCause is just one of these ways. Is it the smartest one? Far from it. But if some developers find it useful, then perhaps the idea may not be as dumb as it sounds.
Did you ever stop to think whether you should do this project just because you could?
I don’t like that phrase; it’s so overused. Can’t someone build something just because it’s fun? Because it’s interesting? Because they might think it could be useful?
So, no, I never stopped to think that. I thought “huh, has this ever been attempted? Why yes, it has been attempted before. Regardless, let’s give this a try; it sounds like a cool way to spend time.”
Do you like Javascript? Are you a masochist?
I absolutely love Javascript. It has its quirks, but it’s such a fun language to work on. I also love Perl and C, as in I love coding in them. I am competent in other programming languages (Java, Perl 5/7), but nothing beats the fun that is coding in Javascript. That doesn’t mean I like its modern ecosystem, though. Hence the idea of JSCause.
Are you trying to replace PHP as the worst backend language ever?
PHP has a bad rap, but I’ve heard it has improved significantly over the years, so maybe the rap is now unfair? But I digress. To answer your question, nah. I just wanted to build something fun and useful. It’s far from perfect, but believe it or not, a lot of thought was put in important aspects such as consistency, security, discoverability, modularity and readability.
How can you sleep at night?
Sometimes I ask myself the same thing.
Should I keep reading this silly FAQ?
There are two more questions left below, so… you may as well.
How can I contribute to JSCause?
The code for the JSCause project is hosted on Github: https://github.com/eighthjouster/jscause/
Feel free to submit a pull request, report bugs, or contact the maintainers for feedback, questions and suggestions.
My question is not answered here. How can I get help?
If you’d like to report a bug or issue with JSCause, please open a ticket on our Github repository: https://github.com/eighthjouster/jscause/
You can also send us an e-mail. Find out more at the About page.