Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the naming rules for JavaScript file names

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "what are the naming rules of the JavaScript file name", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what are the naming rules of the JavaScript file name" bar!

Loading JavaScript in HTML

Use simple syntax to load external scripts (the type attribute is not required):

Access HTML elements

The consequence of using the "untidy" HTML style may be an JavaScript error.

These two JavaScript statements produce different results:

Var obj = getElementById ("Demo")

Var obj = getElementById ("demo")

If possible, use the same naming convention in HTML (just like JavaScript).

Access the HTML style Guide.

File extension

HTML files should use the .html extension (not .htm).

CSS files should use the .css extension.

JavaScript files should use the .js extension.

Use lowercase file names

Most web servers (Apache, Unix) are sensitive to the case of file names:

London.jpg cannot be accessed as a London.jpg.

Other web servers (Microsoft's IIS) are case-insensitive:

London.jpg can be accessed as London.jpg or london.jpg.

If you mix case, you must be strictly contiguous and consistent.

Even this small error can damage your site if you move your site from a case-insensitive server to a case-sensitive server.

To avoid these problems, always use lowercase file names, if possible.

Performance

Computers do not use code conventions. Most rules have little impact on the execution of the program.

Indentation and extra spaces are not important for small scripts.

For scripts under development, readability should be a priority. Larger production scripts should be scaled down.

Thank you for your reading, these are the contents of "what are the naming provisions of JavaScript file names?" after the study of this article, I believe you have a deeper understanding of what the naming provisions of JavaScript file names have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report