Skip to content

[html] 第476天 一般习惯把js写在</body>前,但有例外的情况吗?说说看 #2729

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第476天 一般习惯把js写在</body>前,但有例外的情况吗?说说看

3+1官网

我也要出题

Activity

ruihengChe

ruihengChe commented on Aug 4, 2020

@ruihengChe

有,有写在head里面,还有写在后面
我都是写在后面,把所有代码都写在window.onload函数里面,这样等页面的所有元素加载完毕,js才会执行。

Joevin-Tang

Joevin-Tang commented on Aug 4, 2020

@Joevin-Tang

需要在页面渲染前加载的一般放在head里,类似一些动画库

Mszmy

Mszmy commented on Jan 18, 2021

@Mszmy

js的放置位置有三种:
(1)放在head标签内
(2)放在body标签内
(3)外部script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @haizhilin2013@Joevin-Tang@Mszmy@ruihengChe

        Issue actions

          [html] 第476天 一般习惯把js写在`</body>`前,但有例外的情况吗?说说看 · Issue #2729 · haizlin/fe-interview