Skip to content

Cache the element #3

Description

@nyhtml

Cache the element instead of looking up the element every second:

const clockElement = document.getElementById("clock");

Cache it once.

Example:

const clockElement = document.getElementById("clock");

function getTheDate() {
    if (!clockElement) return;

    ...
    clockElement.textContent = ...
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions