Using Javascript vs HTML to display images

Firstly, sorry for my incredibly noobishness, but I am just starting javascript and have a lot of questions.

1.) Would it be faster loading image through javascript or HTML?

I would assume HTML and also for things like, javascript enabled on browser, it would be safer to use HTML? I am just trying to figure out when it is better to use javascript vs CSS, jquery because the thing I'm working now seems very slow with jquery..


    var img = new Image(100,200);
    img.src = "";


    // This next line will just add it to the <body> tag
  border:1px solid green;
I am but a HTML image<img src="" alt="">

<div id="ok">Hello, I was put here by Javascript</div>

Answers 1

  • Image loading time will be same for both but it may differ. You can check it in network tab. And you can use 'image complete property'.The complete property returns whether or not the browser is finished loading an image.

Related Articles