-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Variables and Operators lesson : Fix misleading Filename #29849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Changed from "no name `.js` " to " `noname.js` " for better clarity, as the former might confuse people into creating a literally empty .js file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the confusion, but what it is saying here is that there is no name. The file is just .js
. I am open to clarifying the sentence.
@@ -65,7 +65,7 @@ Another way to include JavaScript in a webpage is through an external script. Th | |||
|
|||
JavaScript files have the extension `.js` similar to `.css` for stylesheets. External JavaScript files are used for more complex scripts. | |||
|
|||
We named our file `javascript.js` but we could have chosen any name like `my-script.js` or even no name `.js`. What is really important is the `.js` extension. | |||
We named our file `javascript.js` but we could have chosen any name like `my-script.js` or even `noname.js`. What is really important is the `.js` extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We named our file `javascript.js` but we could have chosen any name like `my-script.js` or even `noname.js`. What is really important is the `.js` extension. | |
We named our file `javascript.js` but we could have chosen any name like `my-script.js` or `.js` without a name. What is really important is the `.js` extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://discord.com/channels/505093832157691914/505093832157691916/1391831840867881131
Well, this was the source of the confusion. someone tried it and it gave them an error ( possibly because of the naming? )
I'm not sure, please do clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems if the script src leads to a file name that begins with a dot, the browser interprets the MIME type as text/html
even if it's explicitly set to text/javascript
(which would otherwise be implicit). Tested this with various file names inc. .n.js
and n.js
, both with and without the leading ./
.js
as a plain file name does work when running via node e.g. node .js
but in this example, it'll be better to use an example other than nameless .js
The .js
also isn't the important part either. Naming and src-ing the file javascript.rb
will work just fine (with JS code of course), as long as the path indicates a file (just javascript
no extension will end up with a MIME type of text/html
, even if explicitly set in the script tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried it, and .js
as a plain file name also does work in browser console and also with node .js
as clarified by @MaoShizhong. Thankyou so much for clarification.
Changed from "no name
.js
" to "noname.js
" for better clarity, as the former might confuse people into creating a literally empty .js file.Because
" no name
.js
" can be confusing for people as it might lead them to think its an empty .js file which can cause an error. Changing it tononame.js
can probably help avoid the confusion.[ At the very least, it can be changed from the existing " no name
.js
" to " noname.js
". ]This PR
.js
changed tononame.js
in the variables_and_operators section of the Foundations Course.Issue
Closes #XXXXX
Additional Information
Link to discord discussion : https://discord.com/channels/505093832157691914/505093832157691916/1391852492329062410
Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section