Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the application mode of javascript embedded and outer chain?

Shulou Source: shulou.com Published: 2022-06-02 08:13:33 10月31日 Update

This article introduces the relevant knowledge of "what is the application of javascript embedded and external chain". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The basic Application of javascript embedded and Outer chain

The js language can be completely placed in the HTML language

But depending on the situation, it can be divided into embedded type and outer chain type.

When there is less js code, you can directly use embedded javascript through tags and related attributes

[xss_clean] ("This is a heading"); [xss_clean] ("

This is a paragraph.

")

But in large-scale projects and when there is a lot of javascript code, you need to use the outer chain.

When using outer chain, you need to create a new .js file first.

Put the javascript code that needs to be written in the file of 1245.js

There are three writing modes of JavaScript: inline, inline, outer chain 1, and inline.

Within the attributes of the html tag, the execution is triggered by the behavior. (rarely used)

2. Embedded type

Wrapped with script tags in the html file, the page opens and executes automatically. It's easy to use, but don't use large JS code. )

3. Outer chain type

Written in a separate js file, the src attribute of the script tag is introduced in the html file, and the page opens automatically. (recommended because there are various optimization methods)

Note: it is really rarely used in the industry, hardly at all. Embedded and outer chains cannot share the same script tag. The script tag of the outer chain can be placed anywhere in principle. The script attribute of the outer chain is src, not href, not href, not href.

This is the end of the content of "what is the application of javascript embedded and external chain". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Chain tag file code attribute method application no content situation more knowledge language page practical learned next location easy to use package Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Redmi Docker Shulou Technology