M
M
madcore2015-10-25 00:35:38
css
madcore, 2015-10-25 00:35:38

Why does javascript load 1 but background-image 2?

javascript just started learning.
There is a tag script at the end of the body, but the background does not have time to load. How to fix ?
Like this
- only locally, when 1 time offers to enter there is no background there and loads after the script is completed.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Battle of the ship</title>
  <link rel="stylesheet" href="main.css">
</head>
<body>
  <div class="wrapper">
    <h1 class="mainTitle">Battle of ship</h1>
  </div>
  <script src="code.js"></script>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mark Doe, 2015-10-25
@mourr

You can check if the background image is loaded, and after it is loaded, already run your script
jsfiddle.net/gmzSG/80

R
Radiks Alijevs, 2015-10-25
@dedalik

but the background does not have time to load.

What is it like?
Pictures are loaded separately from scripts

S
Sergey Titov, 2015-10-25
@Nuboskill

I'm afraid to even imagine what kind of background you have there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question