skip to Main Content

Why are there 2 image files being rendered when my html and js have one image.jpg.

I’m using static Html with CSS and JSS and Webpack.

see image below:

issue showing how image is rendered

The code is in Github here: https://github.com/kevindRuby/hello-webpack-eg1

Preferred outcome: For the image to display once on top of blinking text.

2

Answers


  1. You have in your main.js file

    import imageSrc from './image.jpg'; // Adjust the path if necessary
    
    const imgElement = document.createElement('img');
    imgElement.src = imageSrc;
    imgElement.alt = 'Description of image';
    document.body.appendChild(imgElement);
    
    Login or Signup to reply.
  2. In main.html, you explicitly create the image, right after the header.

    You then call your main.js script directly after, where you call the .appendChild() function on the body to create a second image.

    I don’t understand what you mean by "display once on top of blinking text", however you can get rid of the second image by removing the first 5 (6 including the blank) lines of code in your main.js file

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search