# How to preload images from an external js file

**URL:** <https://forum.kirupa.com/t/how-to-preload-images-from-an-external-js-file/261502>\
**Category:** Uncategorized\
**Created:** [May 28, 2008, 8:13am UTC](https://forum.kirupa.com/t/how-to-preload-images-from-an-external-js-file/261502 "2008-05-28T08:13:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Bolero](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@Tony\_Bolero](https://forum.kirupa.com/u/Tony_Bolero)\
**Post date:** [May 28, 2008, 8:13am UTC](https://forum.kirupa.com/t/how-to-preload-images-from-an-external-js-file/261502/1 "2008-05-28T08:13:50Z")

</div>

In Dreamweaver theres a javascript that loads images after the page has finished. Which images is being set in the body tag. I wonder if it is possible to move the code to a external javascript file. The code looks like this

```auto

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Preload images</title>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a*.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a*;}}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('image_1.jpg','image_2.jp g','image_3.jpg')">
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![simplistik](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/simplistik/32/7747_2.png) [@simplistik](https://forum.kirupa.com/u/simplistik)\
**Post date:** [May 28, 2008, 2:56pm UTC](https://forum.kirupa.com/t/how-to-preload-images-from-an-external-js-file/261502/2 "2008-05-28T14:56:21Z")

</div>

> **[PageResource.com - All About Web Development](https://pageresource.com)**
>
> PageResource.com is being discontinued as we’re merging with WebsiteSetup.org If you need web development tutorials, follow the links below (from WebsiteSetup.org) HTML Beginner’s Tutorial HTML Cheat Sheet How to Make a Website: Step by Step Guide If...
